What is PHP?
What is PHP, and what is PHP used for exactly? PHP is a server-side scripting programming speech that's used to acquire static or dynamic websites, or regular web applications.
What does PHP stand for? PHP stands for Hypertext Preprocessor, simply you may agnize it equally the old acronym for "Personal Home Pages."
A script is a set of programming instructions taken at runtime. A scripting language is responsible for interpreting scripts at runtime. The primary objective of a playscript is to escalate the performance of several tasks in an application.
But what is PHP programming, and how can you use it? We'll cover all that now — understand on to gather an introduction to PHP and learn all about its uses in the computer world.
What is PHP Programming?
PHP stands for hypertext preprocessor. The PHP programming nomenclature is a scripting language used widely across the orb, primarily for web development. You can embed PHP into HTML and bring on after that too.
Moreover, PHP is server-side, whereas other computer programming languages equal JavaScript are client-side. The John R. Major conflict between the two is that PHP encipher is executed connected the host that generates HTML, and is sent directly to the client. While the guest ass see the results by running the playscript, they cannot admittance the underlying code.
If you are a beginner, PHP is an super simple language for you to learn. It also comprises advanced features for professed programmers. You can go by writing simple scripts and master the PHP programming language gradually.
Forthwith, let's diving into the phrase structure of PHP.
Phrase structure of PHP
PHP syntax is pretty simple. A PHP file away hindquarters also let in HTML or guest-side script as JavaScript.
Present is the basic syntax of PHP:
<?php echo 'I love programming'; ?> The display screen shows, "I love programming."
When using PHP, continue the following in brain:
- While not essential, some prior reason of HTML is perfect before acquisition the PHP programming language.
- To handle database-power-driven applications with PHP, use database management systems or DBMS .
- You will pauperization XML or JavaScript to fles in advance interactive applications with PHP.
How to Write a Program in PHP
Writing a program in PHP is extremely easy. See the below example:
<!DOCTYPE html> <html> <head> <title>Case</title> </head> <body> <?php echo "PHP Programming is simple."; ?> </consistency> </hypertext markup language> Let's move ahead and know why to use PHP.
Why PHP?
As you know, there are a plethora of programming languages available for you to work with as a web developer. So, what makes PHP stand out from the others? Hera are a few benefits of using PHP:
- PHP is a disembarrass and open-source scripting language.
- PHP is a server-side scripting linguistic process . You can install it connected the server; however, the clients WHO request the resources from the host assume't have to install PHP.
- It is cross-platform , allowing you to use it on various operating systems wish Windows, macOS, Linux, etc.
- PHP comes with a built-in support system , which means that you can use PHP with various database direction systems such as Oracle, Postgres, ODBC, MS, and SQL Host.
- Most entanglement hosting servers support PHP.
- PHP provides you with a huge online residential area with all kinds of support, including documentation guides and problem-solving posts.
- PHP is easy to learn , specially if you have a first knowledge of other programming languages.
- Immense textbook-processing features equal PCRE and Perl
In gain, PHP offers a remarkable feature by supporting a wide range of databases. For example, you can use database-specific extensions like MySQL to write a database-enabled webpage, use an abstraction layer such as PDO, or even build a connection to a database with the ODBC extension.
Furthermore, while victimisation PHP, you can use both objective-oriented programming and proceedings programming. You are not scarcely apprenticed to output HTML; rather, you can output any text alike XML or XHTML. PHP can machine-generate seek files and save them, helping to protect the server-side from forming a stash for the dynamic content.
Now that we know extraordinary of PHP's benefits, let's get into the PHP extensions.
PHP Extensions
PHP files are saved with the ".php" elongation. Roughly of the earlier PHP file extensions include:
- .phps
- .php3
- .php4
- .php5
- .phtml
Where is PHP Misused?
Thither are various W. C. Fields where you can use PHP, and simply these are the three most animated areas to use up it:
- Command-line scripting
- Server-side scripting
- Writing desktop applications
Command-Line Scripting
Individual tasks run in the background of a web host besides web applications for the databases. Each project concludes after a designated number of time. Therefore, every task has its timeline.
Here's an example of command-line scripting in PHP:
Suppose you take over to send an invitation email to your subscribers on a mailing heel. You tail end carry out this tax via web scripting. Nevertheless, the process gets trickier when you reach few hundred subscribers. And, if there are thousands of subscribers, a web script will only have few proceedings for execution, a period known as maximal execution time. At the end of this period, the web host terminates the WWW handwriting and fails to send the email to a portion of the subscribers.
PHP statement-personal credit line scripting can resolve this issue:
With command-line scripts, there is no maximum execution time. The scripts can hightail it as long as the server is active.
Thu, with the help of command-line scripting, any kind of time-consuming tasks such as transferring files to another server via FTP or backing up a complete website or database can be done seamlessly.
Server-Pull Scripting
Server-incline scripting is the most common and frequently used field for PHP. It requires threesome animated components: a webserver, a web web browser, and a PHP parser.
With server-side scripting, you must run the web waiter with installed PHP. Moreover, you can well access and guide any PHP syllabu output through a web browser.
Writing Desktop Applications
If you want to develop a desktop application and a Graphical user interface, PHP may not atomic number 4 the perfect resolution for you. However, to access some high PHP features, you can use PHP-GTK in your client-side applications to write programs.
PHP-GTK is an extension of PHP. However, you may not find IT primarily distribution. To access PHP-GTK, visit the official internet site .
PHP Data Types and Operators
PHP supports a wide set of data types, so much as:
- Integer
- Thread
- Drift
- Array
- Boolean
PHP Whole number
A non-decimal number within the range of -2,147,483,648 and 2,147,483,647 is an integer data type. A number is an integer only when at to the lowest degree united finger is either empiricism or unfavorable. Take a look at the beneath command that takes $z As an integer, with the function var_dump returning the value:
<?php $z =1674; var_dump($z); php?> PHP Train
A PHP string is any episode of characters. Here's the sentence structure to use a string in PHP:
<?php $a = "Hello Programming!"; $b = 'How-do-you-do Scheduling!'; echo $a; echo "<br>"; echo $b; ?> PHP Float
A floating-point number is any come with a decimal point or a number that's present in an exponential form.
Here is an exercise:
<?php $a =3.14; var_dump($z); ?> PHP Array
An lay out holds multiple values in one variable:
<?php $students = align("Daniel","Josh","Sam"); var_dump($students); ?> PHP Boolean
A Boolean is old for conditional examination, and information technology tells you two states:
- True
- Counterfeit
$x = truthful;
$y = dishonest;
Now, let's move along to the PHP operators.
PHP Operators
Operators are primarily victimized to perform different operations on variables. Variant operators in PHP include:
- Logical operators
- Arithmetic operators
- Array operators
- Assigning operators
- Comparison operators
Logical Operators
Logical operators help to combine conditional statements:
| Name of the operator | Sign |
| And | & |
| Or | | |
| Xor | xor |
| Or | || |
| And | && |
| Not | ! |
Arithmetic Operators
Arithmetic operators like additional, deduction, multiplication and segmentation help execute operations with numeral values.
| Name of the manipulator | Signalise | Example |
| Addition | + | $x + $y |
| Subtraction | - | $x - $y |
| Sectionalisation | / | $x / $y |
| Times | * | $x * $y |
| Exponentiation | ** | $x ** $y |
| Modulus | % | $x % $y |
Array Operators
PHP arrays are used to compare arrays:
| Name of the operator | Signboard |
| Union | + |
| Equality | == |
| Inequality | != |
| Identity | === |
| Not-individuality | !== |
| Inequality | <> |
Assignment Operators
Assignment operators assign a prise to a particular variable:
| Operator | Meaning |
| x = y | x = y |
| x += y | x = x+y |
| x -=y | x = x-y |
Comparison Operators
To liken cardinal numbers or strings, we use comparison operators:
| Name of the Operator | Communicatory |
| == | Equal |
| === | Identical |
| !== | Non identical |
| != | Not equal |
| <> | Not equal |
| > | Greater than |
| < | Less than |
| <= | Less than or adequate |
| >= | Greater than or equal to |
PHP Cookies and Sessions
Cookies
We use cookies to distinguish users on a web page. A computer sends a request to a page in the browser, and with it, sends a cookie. In the guinea pig of PHP, you can easily retrieve and create cooky values.
Hither are some commands to create or qualify a cookie:
To make over a cookie, follow this code:
<?php $cookie_name = "user"; $cookie_value = "PhP Programming"; setcookie($cookie_name, $cookie_value, time() + (60*60), "/"); ?> <html> <body> <?php if(!isset($_COOKIE[$cookie_name])) { echo "Biscuit named '" . $cookie_name . "' is non fructify!"; } else { echo "Cookie '" . $cookie_name . "' is set! <br>"; reverberate "Value is: " . $_COOKIE[$cookie_name]; } ?> </organic structure> </hypertext mark-up language> In this code, the phrase structure is:
setcookie(name, value, expire, path, land, secure, httponly);
To modify a cookie, stick to this inscribe:
<?php $cookie_name = "user"; $cookie_value = "XYZ"; setcookie($cookie_name, $cookie_value, time() + (60*60), "/"); ?> <html> <torso> <?php if(!isset($_COOKIE[$cookie_name])) { echo "Cookie titled '" . $cookie_name . "' is non set!"; } other { echo "Cookie '" . $cookie_name . "' is set! <Red Brigades>"; echo "Value is: " . $_COOKIE[$cookie_name]; } ?> </body> </html> To erase a cookie, use this code:
<?php setcookie("user", "", time() - 86400); ?> <html> <physical structure> <?php echo "Cookie 'drug user' is deleted."; ?> </torso> </hypertext markup language> In the lesson above, setcookie here sets the going metre to be a twenty-four hours agone.
PHP Sessions
You can memory boar information with multiple pages by victimisation a PHP academic term, without storing the information in the user's system.
To create a seance, follow this code:
?php session_start(); ?> <!DOCTYPE hypertext mark-up language> <html> <body> <?php $_SESSION["favfont"] = "Arial"; $_SESSION["favbird"] = "piranha"; echo "Session variables are set."; ?> </body> </html> To qualify a session, you backside execute:
<?php session_start(); ?> <!DOCTYPE HTML> <html> <organic structure> <?php $_SESSION["favcolor"] = "yellow"; print_r($_SESSION); ?> </physical structure> </html> Finally, drop a line the following encrypt to cancel a session:
<?php session_start(); ?> <!DOCTYPE html> <html> <body> <?php session_unset(); session_destroy(); ?> </dead body> </html> Conclusion
What is PHP? Standing for Hypertext preprocessor, PHP is an ASCII text file scripting language popularly used in the web development world. PHP is primarily supported server-side scripting; notwithstandin, there is a great deal more to PHP, including its cookies and extensions, benefits, and open-source nature.
Now that you consume a basic PHP introduction, it's clip to apply your knowledge to PHP projects.
Download 10 best PHP projects with source write in code to get several hands-along receive with using PHP.
Check This Run over Out! PHP for Absolute Beginners
DOWNLOAD HERE
What is PHP? Free Download
Posted by: davieswifeentent.blogspot.com

0 Comments