Jump to content

syntax standards question


lc21

Recommended Posts


<?php
echo "<p align='center'><a href='$path'>link</a></p>";
?>

 

In the event of a variable being encorporated into the code is the above method accepated for having the hyperlink url in a variable?

 

Yes, but I prefer to put curly brackets around the variable (see below example). That'll allow you to use arrays in it too, I don't think it will otherwise. Also note that double quotes are required if you need it to parse variables, line breaks (\n), tabs (\t) etc.

 

<?php
echo "bla bla {$var['something']}";
?>

I think this is more of an XHTML standards question. Every documentation that ive seen uses double quotes for enclosing the attributes of a tag. On the other hand, they all tend to just say that the attribute value must be enclosed in quotes(they do not specify double quotes) - but as i say, they all use double quotes in their examples.

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.