PHP is one of the most powerful tools for making dynamic and interactive Web pages. It is primarily focused on server-side scripting. In the current era, PHP has got a massive success due to its three noticing features.
- It is a very easy and forgiving language which can be easily learnt by the developers.
- It is part of the free LAMP stack (Linux, Apache, MySQL, and PHP) and thus available on almost any server you can rent on the Web.
- It does not need any special editor, environment or build process. Whatever you want to do, you just create a file of the .php file type, mix PHP and HTML and then put it on your server for rendering.
Before proceeding further let’s have a glance over what PHP stands for and where it is used most frequently.
What is PHP?
PHP stands for Preprocessor Hypertext and Scripting Language. One can do anything with PHP as any other CGI program can do such as generating dynamic page content, or sending and receiving cookies etc. Then a question can arise in your mind that what is the need of PHP if other CGI program can do the same thing as PHP do. The question is quite obvious. Its apt answer is that PHP can do much more than any other CGI scripting language. PHP has much more abilities to perform far better than any other scripting language. PHP can output images, PDF files and even Flash movies. It can also easily output text such as XHTML and any other XML file. Also, PHP can auto-generate these files, and save them in the file system, instead of printing it out, forming a server-side cache for the dynamic content. Furthermore, one may also have the choice of using procedural programming or object oriented programming (OOP), or a mixture of both.
The PHP interpreter only executes PHP code within its delimiters. Anything outside its delimiters is not processed by PHP. The most common delimiters are to close PHP sections. To clarify the concept, Let us see a simple Hello World Program in PHP:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset=”utf-8″ />
<Title>PHP Test</title>
</head>
<Body>
<? php
echo ‘Hello World’;
?>
</body>
</html>
Where PHP Scripts are used?
PHP (Preprocessor Hypertext) is the most popular and widely used server side scripting language for web development. It is the most common of all server side scripting languages, and efficiently operates on several different types of servers, including Windows, Linux, and UNIX as well.
There are three main areas where PHP scripts are widely used:
1) Server-side scripting: This is the most traditional and main targeted area where PHP are widely used. While in the course of server side scripting, three things are needed which include the PHP parser (CGI or server module), a web server and a web browser. You need to run the web server is needed to run with a connected PHP installation. The PHP program output can be accessed with a web browser, viewing the PHP page through the server.
2) Command line scripting: One can also make a PHP script to run it without any server or browser with the help of PHP parser. This type of usage is ideal for scripts regularly executed using cron (on UNIX or Linux) or Task Scheduler (on Windows).
3) Writing desktop applications: PHP possess some of the advance features which make it the best language to create a desktop application with a graphical user interface. The person having expertise in PHP can use its advanced features to write desktop application programs as well as cross-platform application programs.
One of the noticing features of PHP is its support for a wide range of databases. It can be connected to any database supporting the Open Database Connection standard via the ODBC extension. It is the strongest and most significant features in PHP. PHP has support for the WDDX complex data exchange between virtually all Web programming languages. It has also support for instantiation of Java objects and using them transparently as PHP objects. PHP possess some useful text processing features such as the Perl compatible regular expressions (PCRE), and many extensions and tools to parse and access XML documents. It standardizes all of the XML extensions on the solid base of libxml2, and extends the feature set adding SimpleXML, XMLReader and XMLWriter support.
PHP is very much similar to other high level languages like C, C++, Java, and Perl in context of keywords and language syntax such as if conditions, for and while loops and function returns etc; Basic object-oriented programming functionality was also added in PHP like other object oriented langusge. Let us go through a basic example of object-oriented programming in PHP as given below. It will let you to understand the basic approach of programming in PHP.
class Person {
public $firstName;
public $lastName;
public function_construct ($firstName, $lastName = ”)
{
$this->firstName = $firstName;
$this->lastName = $lastName;
}
public function greet ()
{
return “Hello, my name is” . $this->firstName . ” ” . $this->lastName . “.”;
}
static public function static Greet($firstName, $lastName)
{
return “Hello, my name is” . $firstName . ” ” . $lastName . “.”;
}
}
$he = new Person (‘John’, ‘Smith’);
$she = new Person (‘Sally’, ‘Davis’);
$other= new Person (‘Joe’);
echo $he->greet (); // prints “Hello, my name is John Smith.”
echo ‘<br />’;
echo $she->greet(); // prints “Hello, my name is Sally Davis.”
echo ‘<br />’;
echo $other->greet(); // prints “Hello, my name is Joe .”
echo ‘<br />’;
echo Person::static Greet(‘Jane’, ‘Doe’); // prints “Hello, my name is Jane Doe.”
Listed below are 10 excellent techniques that PHP developers should learn and use every time they program.
Best PHP Tutorials
PHP is a server-side scripting language which is most commonly used on web applications to create dynamic content, and access data from within a database. We are presenting here some of the best PHP tutorials which will acknowledge the PHP developers to a great extent.
Good PHP Tutorials
This tutorial will cover up all the essential techniques and aspects of PHP which will acknowledge PHP developer whether beginner or professional. The developers will be able to learn about uploading files from the browser, sessions, or using PHP to process XML.
PHP Tutorial for Beginners
This tutorial is designed for the person who has the knowledge of HTML but doesn’t know much about PHP. This will acknowledge the beginners with innovative tips and techniques in PHP.
PHP and RSS: Getting it together
In this tutorial the developers will be able to learn both PHP as well as RSS. This tutorial will teach the basics of RSS, some of its many uses, how to use PHP to create an RSS feed from a database, and how to use the XML_RSS module to read an existing RSS feed and translate it into HTML and much more.
PHP in Depth
This tutorial will acknowledge the PHP developers regarding how to use PHP through building a simple workflow application. There will be bulk of knowledge, templates, PHP manuals, content management systems, scripts, classes and much more for the PHP developer.
PHP configuration patterns
This tutorial will present several innovative ideas to build configurable PHP applications. It will cover up entire concepts start from creating a basic PHP page using HTML forms and accessing databases to authentication, streaming files, and how to create objects and exceptions and much more.
PHP Tutorial – Learn PHP
This tutorial is projected to teach you the basics of PHP. This tutorial is intended to the novice developers. It will make you to learn PHP from the ground up.
Regular Expressions PHP Tutorial
This tutorial will explain the basic syntax and semantic of PHP. It will focus on the syntax of regular expressions used in PHP.
Set up a PHP and MySQL development environment
This tutorial will walk you through the process of setting up your Windows XP machine as a PHP and MySQL development environment. It will provide you step by step information about how to set up PHP, Apache, and MySQL as a development environment on a Windows XP machine
Zend Developer Zone
This tutorial will cover several concurrent topics regarding PHP such as using the Plurk API with PHP, Creating Web Page Templates with PHP and Twig etc.
Learn About PHP
This tutorial will make you will learn about PHP, and how to execute scripts on the server.