What is the difference between php4 and php5




















This is a typical PHP 4 code - if you wanted to duplicate an object, you had to copy it and assign a new value to it. In PHP 5 the coder can simply use the "clone". Here is how the same code will look in PHP 5 :.

Since we were chaning only the name, we "cloned" the first object and simply changed the value that needed changing. With PHP 5 you can safely create class constants that act in very much the same way as do defined constants, but are limited within a class definition and can be accessed with "::".

Have in mind that constants must have a constant expression for a value; they can't be equal to a variable or a result of a function call. Here is how you can define a constant: PHP Code:. When a class member is declared as static, it's accessible with "::" without an instance. In PHP 5 another addition is the "visibility" of the class methods and properties.

The visibility has 3 levels:. In PHP 4 the constructor was just a method with the same name as the name of the class. So, if you changed the name of the class, you had to go and update it every time it was used. When used, the code will be executed only when the object is destroyed. With PHP 5 you can also create the so called "abstract" classes. These are classes, which are used only as a model to define other classes.

If a certain class contains abstract method, it must be defined as abstract. The interface will define the methods, which must be implemented in a class. Have in mind that all methods which are defined in an interface must be public. A big advantage of this new addition is that in a class you can implement any number of interfaces. Here is how it all works :. You can only extend an abstract class Also, a class must be defined as abstract if it contains any abstract methods.

And those abstract methods must be defined within the class which extend that abstract class. You can include complete method definitions within the abstract methods of abstract class. This error levels notifies you when you use depreciated PHP code. This function allows you to avoid writing a long list of includes at the top of your script by defining them inside this function. Methods are accessible to everyone including objects outside the classes. And properties readable and writable by everyone including objects outside the classes.

In PHP4, everything was passed by value, including objects. How many ways can we get the value of current session id? What are the features and advantages of Object oriented programming? How can we get second of the current time using date function? What are the advantages of stored procedures, triggers, indexes? What is the maximum size of a database in mysql? Explain normalization concept? What type of inheritance that php supports?

How can we increase the performance of MySQL select query? How can you prevent caching of a certain page please give several alternate solutions? What are the different ways to login to a remote server? Explain the means, advantages and disadvantages? How many ways we can give the output to a browser? What is the default session time in php and how can I change it? Steps for the payment gateway processing? How can we redirect a PHP page? List out different arguments in PHP header function?

What type of headers have to be added in the mail function to attach a file? What is the difference between Reply-to and Return-path in the headers of a mail function? How to store the uploaded file to the final location? What is type juggling in php? Who is the father of PHP? What is the difference between unset and unlink in PHP?

How can we declare cookie in PHP and then how can we expire it? What is difference between abstract class and interface? What is difference between die ; and exit ; in PHP What is the difference between explode ; and split ; methods? What is difference between single quotes and double quotes in php? How to get the student name got maximum marks in a class? Is PHP an interpreted language or compiler language? What is the difference between compiler language and interpreted language?

How can we get the first element of an array in php? What is end function in php? Why we use strpos in PHP? How to get the number of elements in an array using PHP? How can we change the time zones using PHP?

How can we destroy a session in PHP? What is PHP filter? How we can create a zip file using PHP? How to include a file to a PHP page? How to declare an array in PHP?



0コメント

  • 1000 / 1000