Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts

    php for dummies (like me)

    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.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,107
    Thanks
    2
    Thanked 326 Times in 318 Posts
    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.
    Last edited by CFMaBiSmAd; 06-07-2007 at 07:14 AM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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:
    1. Change all short tags into <?php or
    2. 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

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

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

    Last edited by Fou-Lu; 06-07-2007 at 07:19 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •