|
Posted by Steve on 11/01/06 19:38
| > as for php, my goal is to have php parse as little as possible. this
| > includes using ' instead of " when i am not embedding php variables or
|
| OK yeah, when I first started I used the apostrophe so that i could write
| html with double quotes inside php with no errors. Then I just started
| using mainly double quotes. Is there a great difference in speed?
ok, no, to be honest. for *any* programming language you use whether
compiled or scripted, the total amount of time spent processing *your*
actual code is on the order of nano-seconds. there are exceptions however.
BUT, if i have control of something, i ought to be responsible enough to
write it effectively *and* efficiently. further, that getting into that
habit will let you remain happily unaware of the the exceptions are. ;^)
| Yes but I thought there was a compatibility problem with some of it?
only where either the programmer doesn't program correctly or the server
admin doesn't setup php properly in the first place. the example i'm
thinking of is when using xml related things.
xml usually starts like this:
<?xml
strictly speaking, php is supposed to start explicitly like this:
<?php
when usually, php programmers use:
<?
to start php processing what is inbetween.
if the server is set up to support <? as a php tag (which it does by
default) AND all web requests are funnelled through php, then requesting
http://www.example.com/someXml.xml will have disasterous results.
even if it is setup correctly (to only give to php to process things that
ARE php), a php script could have its sole purpose be to create xml
dynamically. in that case, using a tic (') instead of a quote (") will allow
one to build it without error.
there are other issues, but are all easily handled...and i gain much by
using short-tags.
| And
| that if "god forbid" I should have to change hosts and they didn't have
| this set up I would then need to re-edit all code. Which is why I stuck
| with the <?php instead of the short hand version same with the echoed
| variable etc? Which ones are major compatibility problems? As I wasn't
| sure, well you get the picture.
it is a good point, however most server's default configuration is to
support them. second, the replacement is EASY! a well-written regular
expression can fix all the occurances in moments. however, it's kind of a
mute point. you will know BEFORE you ever write a line of code for someone
whether or not they want you using them...or if they have set the server to
support short-tags. if it is something of your own, you can decide what
*you* want to do. if your host has it setup so that they aren't supported,
yet you want them, use ini_set and enable them. ;^)
| OK turning them on is a no go as I don't have access to the ini file, so
how
| would the second option be implemented into a script?
try to turn them on:
ini_set('short_open_tag', 'On');
put that at the top of your script as the first line. then try it out.
Navigation:
[Reply to this message]
|