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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    What exactly is PHP5 Strict?

    Hi

    Can anyone help me by pointing me to a site that explains simply what the differences are bewtween PHP5 Strict and non strict? I am aware of declaring variables and using <?php instead of <php but I suspect there is more to it.

    An online validator with descriptive error messages would be good.

    TIA

  • #2
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry I meant

    "<?php instead of <?"

    Whoops!

  • #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
    E_STRICT will attempt to notify you of any code usage that 'works' but may not work in the future. Unlike deprecated errors that tell you to stop using a particular type of function or signature, E_STRICT will instead inform you that what you're doing works - currently - but is expected to change in the future (and may not work with previous versions properly).

    The only example I can think of off the top of my head is the usage of static scoping in classes in php:
    PHP Code:
    class MyClass
    {
        public function 
    testFunc()
        {
            return 
    __METHOD__;
        }
    }

    $method MyClass::testFunc();
    print 
    $method
    If you've explicitly included E_STRICT (using error_reporting(E_STRICT); or error_reporting(E_ALL | E_STRICT); for examples), it should indicate that testFunc should not be called statically from MyClass since its declared as an object method and not a class method (the signature itself is missing the static keyword). This example should work though since the actual method doesn't attempt to use the '$this' context to implicitly indicate an object method.

    Does that help you?

    Edit:
    BTW, noticed you snuck in there
    I figured you meant ths short tags, though it should be mentioned that php will interpret <script language="php"> as valid identifiers. I've never, not once, used that though.
    Also, things that they plan on actually removing (like allowing call by reference runtime passing) will trigger an E_DEPRECATED notice to tell you to stop using them (they will be gone in php6). The same will apply if they add short open tags to the list (currently I believe it is not on the list).
    Last edited by Fou-Lu; 02-25-2010 at 07:09 PM.
    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 ;)


  •  

    Posting Permissions

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