Jump to content

QUICK help with making a variable a link


man5
Go to solution Solved by man5,

Recommended Posts

$link	=	?><a href="post?id=<?php echo $id; ?>&title=<?php echo $slug_title; ?>"><?php echo $title; ?></a><?php

Basically what I am trying to do is get a url link of a current page that I'll be sending in an email. I have all the $_GET variables I need to duplicate the current url.  For some reason it's giving me an error. 

 

Can you please fix what is shown above into something that'll work?

 

Thanks.

Edited by man5
Link to comment
Share on other sites

It would help us to help you if you would tell us what the error message says.

 

I don't think that is valid code. You start a PHP assignment and drop out of PHP.

You are also echoing values, they are going to go to the output, NOT the variable assignment.

You should just concatenate the variables into a string; or, my personal preference:

 

$link = sprintf('<a href="post?id=%s&title=%s">%s</a>', $id, $slug_title, $title);
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.