View Full Version : php for dummies (like me)

06-07-2007, 08:00 AM
I downloaded this "complete" login system (evolt.org). The description on the site looked great and it looked perfect for integrating ino my system. The code is excellently documented, object oriented, and pretty.

After following the instructions, which involves copying some code from the site and downloading the rest, I proceeded to test it out. Not totally surprised, I ran the home page and got garbage all over the screen. After a while of trying to make it work, I gave up and figured I'd just use the code as a documentation resource and guide for writing my own.

Suddenly it dawned on me that their php tags were "<?" instead of the
"<?php" I learned (only a month or 2 ago when I started learning php). After further inspection into the php.ini file I found the section that turns "short tags" on/off (<? is one, <script> is another). They recommend writing your code with long tags to be on the safe side.

Now the login code is working great.

So, is it true? Should I go in and change all my <script> tags to <SCRIPT language="JavaScript"> and should I change all those <?'s to <?php's in this login code?

Simple questions from simple minds.

06-07-2007, 08:11 AM
Don't bother with any <script> tags.

Either you or the author of the script should change all the <? to <?php to give portable code that will work independent of the server configuration. No code that is intended to be distributed should ever be written using <?.

Edit: Actually NO code should be written using <?. It was a lazy-way bad idea, like register_globals and in fact causes a problem with xml. The opening xml tag is <?xml. If short open tags are enabled, you need to work around any <?xml in your .php file.

06-07-2007, 08:16 AM
Programming for short tags I always thought was risky, much like register globals. I figured people would eventually disable them.
Your javascript only needs changing for compliancy, best to test that to ensure it works.
There are two solutions for your php short tags problem however. Assuming you can't alter the php.ini to change the values, you can either:

Change all short tags into <?php or
Edit a .htaccess file to override the short_tags directive

short_open_tag is a PHP_INI_PERDIR, which means that .htaccess can override the master value. This is helpful for you :)
In .htaccess:
php_flag short_open_tag On
All done :)

Beaten to the point, lol
Good to point out the xml tags as well, I had forgotten about that

Edit edit, lol.
I also assumed you were using apache, I really shouldn't make those assumptions.

06-07-2007, 08:50 AM
i searched/replaced all the <?'s to <?php's - and reset the setting in php.ini to not allow short tags. thanks guys. other than that, it looks like this guy (calls himself Jpmaster77 a.k.a. The Grandmaster of C++) did a great job on this code.