Page 1 of 1

Php code issue

Posted: Mon Dec 14, 2009 8:53 pm
by mrobert
Hi this is the code of php which i am using

original

value="http://www.abc.com/page/123456"


code:

<?php
$url = $_GET['id'];
echo "value="http://www.abc.com/page/$url";
?>

i want to replace the 123456 everytime so i used this. But this is not working. Anything wrong here?

Re: Php code issue

Posted: Mon Dec 14, 2009 10:22 pm
by iamngk
You echo statement line is wrong. It is not properly quoted.

Code: Select all

echo "value=\"http://www.abc.com/page/$url\"";

Re: Php code issue

Posted: Mon Dec 14, 2009 10:54 pm
by Griven
My personal recommendation here is to use single quotes for the PHP echo statements. That way, when you're mixing it with HTML tags that have double quoted attributes, you don't need to throw in those escape characters. You will, however, have to concatenate variables. See the example below.

Code: Select all

$url = $_GET['id'];
echo 'value="http://www.abc.com/page/', $url ,'"';