PHP Tutorials
The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a server-side scripting language designed specifically for web development. PHP can be easily embedded in HTML files and HTML codes can also be written in a PHP file. The thing that differentiates PHP with client-side language like HTML is, PHP codes are executed on server whereas HTML codes are directly rendered on the browser.
PHP | Introduction
The term PHP is an acronym for PHP: Hypertext Preprocessor. PHP is a server-side scripting language designed specifically for web development.
- Websites like www.facebook.com, www.yahoo.com are also built on PHP.
- One of the main reason behind this is that PHP can be easily embedded in HTML files and HTML codes can also be written in a PHP file.
- The thing that differentiates PHP with client-side language like HTML is, PHP codes are executed on server whereas HTML codes are directly rendered on the browser. PHP codes are first executed on the server and then the result is returned to the browser.
- The only information that the client or browser knows is the result returned after executing the PHP script on the server and not the actual PHP codes present in the PHP file. Also, PHP files can support other client-side scripting languages like CSS and JavaScript.
Why should we use PHP?
PHP can actually do anything related to server-side scripting or more popularly known as the backend of a website. For example, PHP can receive data from forms, generate dynamic page content, can work with databases, create sessions, send and receive cookies, send emails etc. There are also many hash functions available in PHP to encrypt user’s data that makes PHP secure and reliable to be used as a server-side scripting language. So these are some of the abilities of PHP that makes it suitable to be used as server-side scripting language. You will get to know more of these abilities in further tutorials.
Even if you are not convinced by the above abilities of PHP, there are some more features of PHP. PHP can run on all major operating systems like Windows, Linux, Unix, Mac OS X etc. Almost all of the major servers available today like Apache supports PHP. PHP allows using wide range of databases. And the most important factor is that it is free to use and download and anyone can download PHP from its official source : www.php.net.
Please refer setting up the development environment and basic syntax of PHP in further articles.
LAMP installation and important PHP configurations on Ubuntu
PHP is the Web development (Server Side Scripting Language) written and developed for web developers.It was developed by Rasmus Lerdorf in 1994, for maintaining his personal homepage. Later he added the feature to communicate with web forms and to connect with databases, named it as Personal Home Page Tools (PHP), Lerdorf wrote those using C binaries.
Let us get started with installing PHP in Ubuntu. In order to test our PHP pages, a server is needed. MySQL database is also required to manage or save data.Don’t worry you don’t have to buy a web hosting for testing your Web pages, I’m going to tell you how to install your own local host web server.
LAMP is basically a collection of software which you require to create the dynamic website and web applications.These tools are capable enough that you don’t require any other tool for the purpose. The interesting thing about LAMP is that all the tools in it are free and open-source.
Software components of LAMP
- Linux is an operating system which UNIX-like and it’s free and open source for development and distribution. All of the Linux based operating systems provide Lamp packages.
- Apache is an HTTP Server which is used to process the HTTP request i.e. the webpages. It is one of the most popular web servers used by the developers around the globe. It is developed and maintain by the Apache Software Foundation.
- MySQL The Role of the RDBMS (Relational Database Management System) in LAMP bundle is played by MySQL. It helps us to save and manage data efficiently.
- PHP is a server-side scripting language used to interact with web server. It embeds with the HTML code.
Installing all components of LAMP together
- Open up your terminal by either going to dash and typing “terminal” or by pressing Ctrl+Alt+T
- Run the following Command to upgrade your index first(recommended)
- $ sudo apt-get update
- Install the LAMP Bundle
- $ sudo apt-get install lamp-server^
Installing all the LAMP components separately
1. Installing Apache 2 Server
To install Apache Server use the command:-
- $ sudo service apache2 restart
Open your browser and check whether the service has properly installed or not.
Type in the URL: –http://localhost
If you are able to see the Default page,You have properly installed your Apache Server.
Else, if you are getting message “Could not determine server”,Then you need to just copy the below command and run it in terminal.
- $ echo “ServerName localhost” | sudo tee /etc/apache2/conf-available/fqdn.conf&& sudo a2enconf fqdn
Test your server again.
2. Installing PHP 5 and MySQL
To install PHP5 and MySQL
- $ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
To Check if PHP is Working
- Go to /var/www/ folder and create a file with .php extension (test.php)
- Type or copy <?phpphpinfo(); ?>and save it.
- Now open up your browser and go to “http://localhost/test.php” if you see the page same as below then php is successfully installed.3. Setting up MySQL Password
Open the terminal and type:-
- $ mysql -u root // MySQL console will open up
- $ mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’) //Open phpMyAdmin portal
Open your Browser and type in http://localhost/phpmyadmin.Username: root and password (blank or either “password”).Configuring PHP (php.ini file)
Editing php.ini file is most efficient and immediate way to affect the PHP’s functionality. As php.ini file is read each time when ever PHP is initialized in other words whenever our server is restarted or whenever httpd is restarted.
Location of php.ini: /etc/php5/apache2/php.ini
1) short_open_tag = off
“<? ?>” these are called short open tags. And if you want to use XML functions then you need to set the “default value” to off.
2) disable_functions=[function1, ……]
PHP has the ability to disable selected functions for security reasons.
3) max_execution_time =30
This will make the script time out in safe mode when the time limit exceeds. In windows, script is aborted based on the memory consumption rather than time.
4) error_reporting =E_ALL & ~E_NOTICE
By default the value is to report all the errorit encounters and should be remain as such.
5) error_prepend_string = [“<font color = ff0000>”]
This flag will print the error message in different colour then normal text in the colour which you have specified in the flag. You should set the flag value to the blink so that your eyes can easily catch thee error message pho has encounter.
6) variables_order = EGPCS
This will tell you the order of execution of the variables that are Environment, GET, POST, COOKIE and SERVER. (i.e. left to right).
Once completing our PHP Training in Delhi, our placement team will assist students to get placed in leading MNCs. Our practical oriented PHP instructing will help students to increase practical knowledge and industry exposure. As leading PHP Training Institute in Delhi, we also dedicated to offer quality education to our students with practical sessions and live examples.
ReplyDeleteFor More Info: PHP Training Course in Delhi