php string variables embedded in HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

while ($data = fgetcsv ($fp, 600, "~")); {
while(cond) ; { ... } unfortunatly does not produce a warning but it means: an empty loop-body followed by another code block (not related to the loop)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

print('<a href="who_are_you.php3?person=' . urlencode($person) . '">Back to Who Are You?</a>');
  • the parameter for print is divided into three parts
  • the single-quoted stringliteral '<a href="who_are_you.php3?person='
  • the function-call urlencode(...)
  • the single-quoted literal '">Back to Who Are You?</a>'
all three are concatenated to one string.

Code: Select all

<?php
$part1 = '<a href="who_are_you.php3?person=';
$part2 = urlencode($person);
$part3 = '">Back to Who Are You?</a>';
$concat = $part1 . $part2 . $part3;
print($concat);
?>
permutations
Forum Commoner
Posts: 52
Joined: Sat Dec 07, 2002 11:45 am

Post by permutations »

while(cond) ; { ... } unfortunatly does not produce a warning but it means: an empty loop-body followed by another code block (not related to the loop)
Oh my goodness--I see! One misplaced semi-colon. DUH!! I'm blind. Thank you!
permutations
Forum Commoner
Posts: 52
Joined: Sat Dec 07, 2002 11:45 am

Post by permutations »

Thank you! I see!! I was parsing it in my mind all wrong. I was looking at:
' . urlencode($person) . '
versus
'urlencode($person)'
I didn't realize that the single quotes went with strings on either side, and not the urlencode call. What confused me was the double quotation marks within the single-quoted literals. I thought they were defining a string. I understand now that they are not.

You have explained so many things that have puzzled me. I'm very grateful.
Post Reply