What is PHP? How does PHP work?

Whenever anyone is learning PHP, the most common questions that first come up are: What is PHP? And how does it work?

It is precisely these questions we will look at in this lesson. It’s a big help to understand such basics related to PHP before you start developing you own PHP pages. Such basic understanding will increase the speed of learning significantly.

So, let’s get started!

What is PHP?

PHP was originally an acronym for Personal Home Pages, but is now a recursive acronym for PHP: Hypertext Preprocessor.

PHP was originally developed by the Danish Greenlander Rasmus Lerdorf, and was subsequently developed as open source. PHP is not a proper web standard – but an open-source technology. PHP is neither real programming language – but PHP lets you use so-called scripting in your documents.

To describe what a PHP page is, you could say that it is a file with the extension .php that contains a combination of HTML tags and scripts that run on a web server.

How does PHP work?

The best way to explain how PHP works is by comparing it with standard HTML. Imagine you type the address of an HTML document (e.g. http://www.mysite.com/page.htm) in the address line of the browser. This way you request an HTML page. It could be illustrated like this:

The figure shows a client that requests an HTML file from a server

As you can see, the server simply sends an HTML file to the client. But if you instead type http://www.mysite.com/page.php – and thus request an PHP page – the server is put to work:

The figure shows a client that requests a PHP file from a server

The server first reads the PHP file carefully to see if there are any tasks that need to be executed. Only when the server has done what it is supposed to do, the result is then sent to the client. It is important to understand that the client only sees the result of the server’s work, not the actual instructions.

This means that if you click “view source” on a PHP page, you do not see the PHP codes – only basic HTML tags. Therefore, you cannot see how a PHP page is made by using “view source”. You have to learn PHP in other ways, for example, by reading this tutorial.

What you learn in this tutorial is to write commands to a server!

So, the first thing you need to get ahold of is… a server! But don’t worry – you don’t need to buy a new computer. You just need to install some software on your computer that makes it function as a server. Another option is to have a website on a hosted server that supports PHP. Then you just need to be online while coding.

The next lesson is about how to get your computer to act as a server.

How To Send Plain Text Mail Using PHP Mail Function

How-To-Send-Plain-Text-Mail-Using-PHP-Mail-Function-ask2guruji.org-blogger-ashok-punetha

How To Send Plain Text Mail Using PHP Mail Function

PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient’s email address, the subject of the the message and the actual message additionally there are other two optional parameters.

Here is the description for each parameters.

Sr.No Parameter & Description
1 to

Required. Specifies the receiver / receivers of the email

2 subject

Required. Specifies the subject of the email. This parameter cannot contain any newline characters

3 message

Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters

4 headers

Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n)

5 parameters

Optional. Specifies an additional parameter to the send mail program

As soon as the mail function is called PHP will attempt to send the email then it will return true if successful or false if it is failed.

Multiple recipients can be specified as the first argument to the mail() function in a comma separated list.

[php]
<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$txt,$headers);
?>
[/php]

 

Is PHP A Case Sensitive Language ? What Is Case Sensitive ?

What Is Case Sensitive Is PHP A Case Sensitive Language - ASK2GURUJI - BLOGER ASHOK PUNETHA

Is PHP A Case Sensitive Language ? What Is Case Sensitive?

Is PHP A Case Sensitive Language ?

Is PHP A Case Sensitive Language: Yes, PHP is case sensitive in regards to function only but it should not include the function(s) which is defined by the user.

Previously we read What is PHP How Does PHP Work ?

For e.g. one have defined the function “abc” it must be called by “abc” only nd if function defined “XYZ” it must be called by “XYZ” to pass the query. But if one can call “abc” function by “ABC” OR “XYZ” function by “xyz”, it could not pass the query because of mismatch of case.

What Is Case Sensitive?

Is PHP A Case Sensitive Language ?
Text or typed input that is sensitive to capitalization of letters. For example, “Computer” and “computer” are two different words because the “C” is uppercase in the first example and lowercase in the second example. On modern systems, passwords are case-sensitive, and usernames are usually case-sensitive as well.
If you are unable to log into a computer or account, make sure the caps lock key is not on and that you are using the correct case for each letter in your username and password.
Anything that is not case-sensitive means that any uppercase or lowercase character can be entered. For example, the Windows command line or MS-DOS is not case-sensitive, however, the Linux command line is case sensitive. In other words, you could type “cd”, “CD”, “Cd”, or “cD” for the cd command in the Windows command line without error, but only “ls” will work for the ls command in Linux. Typing in “LS” would generate an error.

Basic PHP Syntax and Comments in PHP

Basic PHP Syntex and Comments - ASK2GURUJI - BLOGGER ASHOK PUNETHA

Basic PHP Syntax and Comments in PHP

A PHP script can be placed anywhere in the document.

A PHP script starts with <?php and ends with ?>:

<?php
// PHP code goes here
?>

The default file extension for PHP files is “.php”.

A PHP file normally contains HTML tags, and some PHP scripting code.

Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function “echo” to output the text “Hello World!” on a web page:

Example

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code.

Comments can be used to:

  • Let others understand what you are doing
  • Remind yourself of what you did – Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code

PHP supports several ways of commenting:

<?php
// This is a single-line comment

# This is also a single-line comment

/*
This is a multiple-lines comment block
that spans over multiple
lines
*/

// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>

 

What is PHP How Does PHP Work ?

What Is PHP How Does PHP Work - ask2guruji - blogger ashok punetha

What Is PHP How Does PHP Work ?

Whenever anyone is learning PHP, the most common questions that first come up are: What is PHP? And how does it work?

It is precisely these questions we will look at in this lesson. It’s a big help to understand such basics related to PHP before you start developing you own PHP pages. Such basic understanding will increase the speed of learning significantly.

So, let’s get started!

What is PHP?

PHP was originally an acronym for Personal Home Pages, but is now a recursive acronym for PHP: Hypertext Preprocessor.

PHP was originally developed by the Danish Greenlander Rasmus Lerdorf, and was subsequently developed as open source. PHP is not a proper web standard – but an open-source technology. PHP is neither real programming language – but PHP lets you use so-called scripting in your documents.

To describe what a PHP page is, you could say that it is a file with the extension .php that contains a combination of HTML tags and scripts that run on a web server.

How does PHP work?

The best way to explain how PHP works is by comparing it with standard HTML. Imagine you type the address of an HTML document (e.g. http://www.mysite.com/page.htm) in the address line of the browser. This way you request an HTML page. It could be illustrated like this:

The figure shows a client that requests an HTML file from a server

As you can see, the server simply sends an HTML file to the client. But if you instead type http://www.mysite.com/page.php – and thus request an PHP page – the server is put to work:

The figure shows a client that requests a PHP file from a server

The server first reads the PHP file carefully to see if there are any tasks that need to be executed. Only when the server has done what it is supposed to do, the result is then sent to the client. It is important to understand that the client only sees the result of the server’s work, not the actual instructions.

This means that if you click “view source” on a PHP page, you do not see the PHP codes – only basic HTML tags. Therefore, you cannot see how a PHP page is made by using “view source”. You have to learn PHP in other ways, for example, by reading this tutorial.

What you learn in this tutorial is to write commands to a server!

So, the first thing you need to get ahold of is… a server! But don’t worry – you don’t need to buy a new computer. You just need to install some software on your computer that makes it function as a server. Another option is to have a website on a hosted server that supports PHP. Then you just need to be online while coding.

The next lesson is about how to get your computer to act as a server.