Wednesday, August 26

Difference between PHP4 and PHP5

There are some 27 differences which I got to  know between PHP4 and PHP5:

    1. PHP5 removed register_globals, magic quotes, and safe mode. This was due to the fact that register_globals had opened security holes by intentionally allowing runtime data injection and the use of magic quotes had an unpredictable nature.
   
    2. PHP4 was powered by Zend Engine 1.0, while PHP5 was powered by Zend Engine II.
   
    3. PHP5 replaced magic quotes with the addslashes() function in order to escape characters.
   
    4. PHP4 is more of a procedure language while PHP5 is object oriented.
   
    5. In PHP5 one can declare a class as Abstract.
   
    6. PHP5 incorporates static methods and properties.
   
    7. PHP5 introduces a special function called __autoload()
   
    8. PHP5 allows one to declare a class or method as Final
   
    9. PHP5 introduces a number of magic methods, such as __call, __get, __set and __toString
   
    10. In PHP5, there are 3 levels of visibilities: Public, private and protected.
   
    11. PHP5 introduced exceptions.
   
    12. In PHP4, everything was passed by value, including objects. Whereas in PHP5, all objects are passed by reference.
   
    13. PHP5 introduces interfaces. All the methods defined in an interface must be public.
   
    14. PHP5 introduces new error level defined as 'E_STRICT'
   
    15. PHP5 introduces new default extensions such as SimpleXML, DOM and XSL, PDO, and Hash.
   
    16. PHP5 introduces new functions.
   
    17. PHP5 introduces some new reserved keywords.
   
    18. PHP5 includes additional OOP concepts than php4, like access specifiers , inheritance etc.
   
    19. PHP5 includes improved support of current content management systems.
   
    20. PHP5 includes reduced consumption of RAM.
   
    21. PHP5 introduces increased security against exploitation of vulnerabilities in PHP scripts.
   
    22. PHP5 introduces easier programming through new functions and extensions.
   
    23. PHP5 introduces a new MySQL extension named MySQLi for developers using MySQL 4.1 and later.
   
    24. In PHP5, SQLite has been bundled with PHP.
   
    25. PHP5 introduces a brand new built-in SOAP extension for interoperability with Web Services.
   
    26. PHP5 introduces a new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa.
   
    27. In PHP5, streams have been greatly improved, including the ability to access low-level socket operations on streams.

PHP4 vs PHP5 (Additional Features of PHP5)

Constructors and Destructors

    In PHP4, Constructor have same name as the Class name.
    In PHP5, name Constructors as _construct and Destructors as _destruct().

Passed by References

    In PHP4, everything was passed by value.
    In PHP5, all objects are passed by references.

Abstract

    In PHP5, we can declare a class as abstract.

Static Methods and Properties

    In PHP5, Static Methods and Properties are also available. When you declare a class as static, then you can access using :: operator without creating an instances of class

_autoload()

    PHP5 introduces a special function called _autoload().

Final

    PHP5 allows you to declare a class or method as final.

Magic Methods

    PHP5 introduces magic methods such as _call, _get, _set and _tostring

Visibility

    PHP5 has 3 level of visibilities
    Public: methods are accessible to everyone including objects outside the class
    Private: methods are accessible to the class itself
    Protected: methods are accessible to the class itself and inherited classes.

Exception

    PHP5 introduces exceptions handling.

Interfaces

    PHP5 introduces Interfaces.

E-Strict Error Level

    PHP5 introduces new error level defined as E_STRICT.
    E_STRICT will notify you when you use depreciated code.

Extensions

    PHP5 introduces new default extensions.
    Simple XML
    DOM and XSL
    PDO
    Hash

Sunday, August 2

jQuery for Validate Forms.

Validetta

Using callback functions
onValid() and onError()

Warning!
    To show error messages healthy, each field must be wrapped by an element like <div>

<div id="alert"></div>
<form id="exm" method="POST" action="#">
    <div>
        <label>Required, Email :</label>
        <input type="text" name="name" data-validetta="required,minLength[2],maxLength[3]">
    </div>
    <div>
        <label>Email :</label>
        <input type="text" name="email" data-validetta="required,email">
    </div>
    <button type="submit">Submit</button>
    <button type="reset">Reset</button>
</form>

<script>
    (function($){
        $('#exm').validetta({
            onValid : function( event ) {
                event.preventDefault();
                $('#alert').empty()
                    .append('<div class="alert alert-success">Nice, Form is valid</div>');
            },
            onError : function( event ){
                $('#alert').empty()
                    .append('<div class="alert alert-danger">Stop bro !! There are some errors.</div>');
            }
        }); 
    });
</script>


Plugin Download