简体   繁体   中英

Php syntax error, little help

I have this string:

$imagename ="$ad_id_stripped"."_1".".jpg";
$display_table.="<a href='../ad.php?ad_id=$row[ad_id]' target='_parent'>
<img style='border:none;' src='../ad_images/$category/thumbs/$imagename?time()' class='shadow'></a>";

echo $display_table;

As you maybe can see I am trying to add the time() function in there... However, there is no time() added to it like this! I have tried with various quotes etc without luck...

Any ideas?

Thanks

$imagename ="$ad_id_stripped"."_1".".jpg";
$display_table.="<a href='../ad.php?ad_id=$row[ad_id]' target='_parent'>
<img style='border:none;' src='../ad_images/$category/thumbs/$imagename?" . time() . "' class='shadow'></a>";

echo $display_table;

You want to get the time() function out of the string itself and concatenate

You can't do:

$string = "....time()...";

You will need to do:

$string = "..." . time() . "....";

or

$time = time();
$string = "....$time...";

Strings wrapped in double quotes will parse variables, but not functions. Try this:

$imagename ="$ad_id_stripped"."_1".".jpg";
$time = time();
$display_table.="<a href='../ad.php?ad_id=$row[ad_id]' target='_parent'>
<img style='border:none;' src='../ad_images/$category/thumbs/$imagename?$time' class='shadow'></a>";

echo $display_table;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM