PHP(Hypertext Preprocessor)

PHP is a scripting language especially suited for web development and can be embedded into HTML. PHP is a interpreted language. PHP stands for Hypertext Preprocessor.The Father of PHP is Rasmus Lerdorf. PHP originally was called as Personal Home Page, later now it stands for Hypertext Preprocessor.

Features of PHP
  • PHP is cross platform - supports any type of operating system. Eg: Windows, Linux, Unix, MacOS
  • PHP is cross server - can run in any type of webserver. Eg: IIS, Apache, TOMCAT etc
  • PHP suppoerts any type of databases and it has no of libraries to communicate with database directly.
  • It contains MySQL library interact with mysql database.
  • Zend engine is a virtual machine of PHP. It executes the php script very fast.
  • PHP is opensource software, it is extensible.
  • PHP 5.0 supports no of object oriented programming concepts like inheritance, access specifiers, abstract classes, interfaces etc.
  • PHP supports different types of Content Management frameworks like Joomla, drupal, oscommerce etc
  • These frameworks provide predefined modules by accessing these features we can develop the PHP application within short time.
  • PHP supports different types of editors.
  • Zend organization providing complete support to the PHP programmers and they introduced no of editors to work with PHP.
  • PHP is very easy to learn and implement the application.
PHP Comments

Comments are used to clarify source code. comments in PHP are:
These are used for single line comment: #,//
For multiline comment: /% %/( for multiline code).

o/p function of PHP: By using this function we can display the messages on web page. This function returns a Boolean value true. We cannot print multiple statements using this function.

By using echo we can print multiple statements in webpage. Compare with print echo is faster because it won't return any value.

  • printf: We can print the statements using format specifiers.
  • sprintf: It is same as printf but it will not print any output on the webpage. Instead of that it returns the output.
  • var_dump: This function returns the variable value along with the datatype.
Types of errors in php:
  • Notice: Notice is type of message usually occurred on webpage when the specified name is not available. We are trying to access undefined variables the o/p is notice.
    By default PHP will not display the notices on webpage because in php.ini one configuration directory is available related to the error messages i.e,
    error_reporting=E_ALL & ~E_NOTICE
    means it displays all error messages except notices. By removing this & ~E_NOTICE
    we can display the notices on webpage.
    Otherwise we can use error_reporting(E_ALL) in webpage. Notice messages will not stop the execution of the rest of the script.
  • Warnings:Like notices we can execute the rest of the statements when warning error is occured. If we are trying to call undefined constants the o/p is warning message.
  • Fatal error: Fatal errors can stop the execution of rest of the script if we are trying to access the undefined functions the o/p is fatal error.
  • Parse error(syntax error): There is any syntax mistake in the script the o/p is parse error. Stops the execution of entire script.