Jump to content

syntax standards question


lc21

Recommended Posts

Hi is it standard when using PHP to use single quotes aroud the center attribute, I am aware that it can be done in other ways but I am just wondering if there is a standard or is the following method ok?

 


<?php
echo "<p align='center'></p>";

?>

Link to comment
Share on other sites


<?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?

Link to comment
Share on other sites


<?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']}";
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.