720Part IVConnectionsOperatorsThe assignment operators (=, +=, *=, and (Web design tools)

720Part IVConnectionsOperatorsThe assignment operators (=, +=, *=, and so on), the Boolean operators (&&,||, !), and thebasic arithmetic operators (+, -, *, /, %) all behave as they do in Java. Other operators aresimilar, with some syntax differences. The string concatenation operator, for example, in PHPis a period (.) rather than a plus sign (+) as in Java. Object modelThe Java programmers coming to PHP with version 5 can rejoice! You no longer need tounlearn your approach to OOP in order to deal with the often crude OOP support in PHP4and earlier versions. With recent changes, the object model in PHP has moved closer toJava s. PHP5 now supports interfaces, and sports a limited version of object overloading. Theaddition of keywords (such as private, protected, and public) for dealing with membervariables should also prove familiar to Java coders. New error handling methods, includingthe built-in Exceptionclass, also seem to borrow a page from Java. See Chapter 20 for much more detailed information about PHP5 s new object model. Memory managementUnder normal circumstances, PHP s garbage-collected environment ensures that you do notneed to explicitly free allocated memory. If you re used to Java s mostly automated garbage- collected heap, you ll be right at home here. Packages and librariesMany Web-specific libraries are built into PHP and are available by default or with minorchanges. This works similarly to the standard Java packages that are available through JARfiles and CLASSPATHreferences. DifferencesThough many of the new features of PHP5 have a Java-like feel, there are plenty of notableexceptions to the way Java and PHP operate. As a general rule, never assume that a Java feature or concept will carry over completely into PHP. Compiled versus scriptingUnlike Java, PHP is a scriptinglanguage. The development cycle is edit-executerather thanedit-compile-execute, as in Java. PHP code is automatically compiled at execution time anddoes not produce native standalone executables. As a result, the developer is not subjectedto rigorous compile time error checking as in Java; many of the errors that you are used toseeing at compile time will not rear their ugly heads until the code is executed in PHP. Variable declaration and loose typingGet used to that leading $. Unlike in Java, all variables in PHP must begin with a $. Variablesneed not be declared before use, nor cast to a different type as in Java. Rather than the Java code: String preamble = new String(); Preamble = We, the people… ; Cross- Reference44
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Leave a Reply