I’ve purchased the Hosting services from CPWebHosting to practice PHP & MySQL and I’m quite satisfied with their monthly hosting plan. PHP is most reliable programming language and is being most popular among us beginners, who have just started learning programming language. Whatever I’m learning in the school, I’m practicing on the domain which I have got from cpwebhosting.
So, far I have learned the basics of PHP in which I’m able to create variables, logical expressions, loops and functions. I’m able to connect PHP to MySQL database and learning to create the complete application. I’m creating the application, in which I’m creating good navigation system, forms, validation in form entries and a password protected admin area.
Still my curriculum includes CRUD routines for updating the database, debugging techniques and usable user interfaces application with site navigation, form validation, and a password-protected admin area.
It is best way to practice PHP by creating the live examples and reinforce various techniques to improve the existing code.
In our school, for first few days, we we were taught the basics of PHP, its installation and configuration. With PHP we were being asked to configure MySQL. Then we started learning different data types in PHP. How we can control code with logical expressions and loops? We used built in functions of PHP, and then started writing our own custom custom functions. This was the starting and it helps us in creating the dynamic websites. Now we are well versed with creating forms and how data will be controlled in forms and how to embed it in database. We are now able to use cookies and sessions to store data. All wonders started when we were able to connect MySQL with PHP. We starting manipulating the data, creating data, editing it. We learn what records are, what are fields. How we can optimize our databases? We started looking to the codes of various CMS available, like WordPress,
Joomla and Drupal and tried to understand, how their programmers have done the things beautifully. I liked the user authentication system of these CMS. Let me show you how a beginner can start with PHP, let us write one short program In this program I have embedded PHP code in HTML
[quote]
<html lang=”en”>
<head>
<title>
learning php
</title>
</head>
<body>
<?php
$number=array();
?>
</body>
</html>
Here is one more program, in which I have used the control structures of PHP:
<html lang=”en”>
<head>
<title>
Learning Control Structures with PHP
</title>
</head>
<body>
<?php
$a = 10;
$b = 15;
if($a > $b)
echo “a is greater than b”
elseif ($a < $b)
echo “a is less than b”
else
echo “a is equal to b”
?>
</body>
</html>
Let us take one more example in which I have used control structures loops:
<html lang = “en”>
<head>
<title>
Learning Control Structures with PHP
</title>
</head>
<body>
<?php
$count=0;
while($count<=10)
{
echo $count. ‘ ‘;
}
?>
</body>
</html>
[/quote]
You see, I have embedded all the php code in HTML, that is because PHP is a scripting language, which runs on server. Thus we can say that it is server-side scripting language. Well, earlier I said, we are learning programming language, but PHP is not programming language it is scripting language. Then, how this difference comes out to be. Let us answer why, it is not programming language:
- PHP runs only in response to an event. It does not runs automatically, when the page is requested only then the PHP runs.
- Instructions are being performed from top to bottom. PHP page once requested, it loads and then runs from top to bottom.
- There is little or no-interaction with user.
While if we look into the properties of Program:
- Program runs, even when there are no events.
- Program jumps into the various sections. There can be several start and end points, or we can say that there is no clear start or end point in programming language.
- Program may include lot of user interaction. Once the applications are launched, it keeps on running, waiting for user input. Program jumps to the various instructions, according to the task you want it to perform.
But, these days, scripts are more efficient to be programs. Technically we can say that PHP is not a programming language, but the differences have become too blurred. Structures are made available in the scripts itself.
PHP is totally a server side scripting language, as its codes runs on server i.e. web server. We understand, that the code will run on server, not on our local PC. We find lot of scripts like javascript or vbscript on our browser i.e. client end.
When we request a page, a javascript or vbscript code is sent at the user end and it then runs there, while PHP code is never sent at the user end, it runs only on server. Results of the PHP program are only sent to the browser. As PHP code cannot run on its own, it always requires Web server to run. Web server runs the PHP exactly as it is written, it does not requires any compilation, like our other programming languages do like Java or C. Code of Java or C need to converted to the binary form, before then runs. PHP is designed to be used with HTML, it can be embedded in HTML or it can generate HTML. PHP results are basically the html codes written to the browsers. Programs of the php programmer are with .php extension and that is of HTML are of .htm or .html. The extension to a program is sufficient for the Web Server to know that it is which type of program, if it is .php, web server knows that there is code in it which need to be executed.
If the html code is what our browser receives, then why not to straight forwardly write the html code instead of php. The reason is that php provides greater flexibility than html. Html pages are static in nature, they remains same all the time, while PHP generates dynamic pages, which are being generated under different conditions according to the user interaction or data stored in databases. Structures of C, java, perl and PHP are very similar with very minute differences. It means learning PHP is easy and I’m lucky to star PHP with cpwebhosting.
Leave a Reply