lc21 Posted July 17, 2007 Share Posted July 17, 2007 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>"; ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 17, 2007 Share Posted July 17, 2007 <?php echo '<p align="center"></p>'; ?> <?php echo "<p align=\"center\"></p>"; ?> Quote Link to comment Share on other sites More sharing options...
lc21 Posted July 17, 2007 Author Share Posted July 17, 2007 Thanks for the reply are both methods ok to use or is there a prefered standard? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 17, 2007 Share Posted July 17, 2007 they are both fine to use. basically it is personal preference. I usually go with the first way. Quote Link to comment Share on other sites More sharing options...
lc21 Posted July 17, 2007 Author Share Posted July 17, 2007 <?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? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 17, 2007 Share Posted July 17, 2007 <?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']}"; ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.