PHP echo problem
What is wrong in the following code?
<?php
echo "<td class='column1'><a href='#' OnClick='windowpopup(". secure_base_url()`"product/item/". $itemid ."/); return false;'>$row->title</a></td>";?>
?>
Why doesn't a pop开发者_C百科up window come up?
After OP Clarification:
After viewing hidden HTML, I must say here's how your code should look like:
<?php
echo "<td class='column1'><a href='#' OnClick='windowpopup(\"". secure_base_url() ."product/item/". $itemid ."/\"); return false;'>{$row->title}</a></td>";
?>
The reason is same though. You need to escape correctly and use double quotes for variables to expand in PHP.
Old Answer
Use this:
echo "{$row->title}";
Or
echo $row->title;
The PHP String Documentation says that:
"The most important feature of double-quoted strings is the fact that variable names will be expanded."
So, to expand variable names, either use double quotes and as precaution enclose them in {}
OR do not use quotes at all.
String interpolation in PHP only works in double quotes.
Whats the value of $row->title
. Also, using single quotes will print the variable name, rather than its value.
edit: Ahh so there is more. Shamittomar, seems to have fixed your problem =)
精彩评论