Jump to content

QUICK help with making a variable a link


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.

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.