I have been writing PHP for more than a decade (almost two, I believe) and developed the habit, right from the beginning, of not including the php in the tag.
The filename (extension actually) is enough of a clue to the server.
Of course, it is considered better form to be more explicit. But as a typical (ie lazy) developer I want the fewest keystrokes necessary.
I have actually came across <? blabla.... ?> where it would not work on a server, found out the hard way after spending hours trying to figure out what was wrong (felt stupid when I figured it out). Anyways out of habit I just include php, it’s only three letters which shouldn’t be a problem even for the laziest programmers.
Thank you all for your reply, but I think that TechnoBear is right when she said :
and for that I asked the question. And about your comment Pepster :
[quote=“Pepster, post:4, topic:115717”]
Anyways out of habit I just include php, it’s only three letters which shouldn’t be a problem even for the laziest programmers.
[/quote] it is funny and I agree with you, but when you insert a lot of php codes in an html page, it will be counted, no ?
Anyways, your comments guy are always helpful…thanks again
I think I did not explain exactly what I mean. I was talking about the number of letters that you type, 4 instead of 1. Anyways, this will never bother me to type ?php, I just want to know if it is right to write it without “php” and got the anwer. But, as there is discussion about this point, I prefer to write always as I learn :
Why does that matter? Why do we care about character count of a PHP page?
The PHP gets parsed, it isn’t in the end result that is served to the user, so all of the PHP code is purely for processing and doesn’t make its way to the end user.
Also, you really should look into MVC to help reduce the HTML/PHP inter-mixing. The end result will give you a much cleaner and easier to maintain application. I’d start with a few searches in the PHP category and then work up any additional questions you may have on MVC into a new topic.
I took that to mean @bbparis was replying to @Pepster who had said “it’s only three letters”, to add that when you’re in and out of php many times in a large page, those three letters mount up each time you type them, rather than a performance issue.
As of PHP 5.4 the short echo tag, <?= , has been available regardless of the setting of php short tags. That was the compromised reached regarding their use.
The short tag plays hell with validators and IDE’s, but not so much for browsers since it’s already been parsed.
Code portability issues are overstated in my opinion. The vast majority require mod_rewrite to be setup somehow, usually through an .htaccess file. It is flat out impossible to stop your .htaccess file from turning on short tags using the appropriate php_flag. This said, I’ve never used the short tag myself, though I do use the short echo tag.
I am getting the same error as you Space Phoenix viz. Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in /home/petalsan/public_html/testingfooter.php on line 1
in a new page I am coding having PHP set up as <?php
// code here
How do I get the code to run? It is on a remote site.
The silly thing is that I have PHP is some other pages as <?php include 'navigation.php'; ?>
and they work fine.