Page Content

Tutorials

What is PHP? What is server side scripting language in PHP?

What is PHP?

What is PHP
Hypertext Preprocessor

PHP is a popular and free web development programming language and interpreter. The language is mostly used for server-side scripting, but command-line scripting and desktop programs are also possible. The PHP Group calls PHP: Hypertext Preprocessor a “recursive acronym.” The initial root of the acronym was Personal Home Page Tools.

PHP server-side scripting generates dynamic browser content. The page is sent to the browser after the web server has executed the script. PHP must be installed on the server, along with a PHP parser (either a server module or a Common Gateway Interface (CGI) parser), in order for the web server to implement this procedure.

In response to a user’s request for a webpage, the parser decodes the PHP component of the page, executes the PHP script’s specified actions, and produces the Hypertext Markup Language (HTML) that emerges from those actions. The content is rendered smoothly once the HTML and any additional HTML on the page are transmitted to the client browser. Pages with PHP script are referred to as dynamic HTML pages since the content changes according to how the script is interpreted.

What is server-side scripting in PHP?

The entire webpage may consist of a PHP script, or it may have one or more PHP scripts embedded in regular HTML components. In either scenario, the web server is alerted that the page contains PHP script by assigning the.php file extension to the webpage itself. A basic HTML page called test.php with an embedded PHP script displaying the current day’s date is demonstrated by the code below:

<!DOCTYPE html>
<html>
<head>
  <title>HTML example</title>
</head>
<body>
  <h2>Example of HTML in action</h2>
  <?php
    $text =  "This is a test HTML script.";
    $date = date("M j, Y") ;
    echo $text." Today's date is <b>".$date."</b>."
  ?>
</body>
</html>


Standard and elements are included in the majority of the page’s basic HTML content. Yet, a PHP script is also included in the section; it is encapsulated in the PHP start and end tags, respectively. Whether PHP scripts fill the entire page or are embedded like the one displayed below, they must always be contained within these tags.

This script defines $text and $date. The former is allocated a string value, while the latter is assigned the current date that was obtained using the date function. After the two variable definitions, there is more text and an echo statement that concatenates the variables. A period (.) is used by PHP to concatenate several items. Additionally, the echo phrase includes the typical HTML syntax and , which indicate that bold text should be used to represent the date.

The PHP parser and web server read the PHP script and return standard HTML when a client browser goes to the test.php page. As seen in the Google Chrome browser, this figure depicts the webpage. It is the PHP script that created the text underneath the main heading.

Apache, Microsoft Internet Information Services, Linux, macOS, Windows, and Unix support PHP. PHP supports MySQL, SQLite3, MongoDB, dBase, PostgreSQL, IBM Db2. PHP communicates with other services using SNM, IM, and LDA.

PHP and Microsoft’s open-source ASP: NET are often compared. PHP scripts can be included in webpages alongside HTML elements, just like ASP.NET.

Open source and free is PHP: GitHub is where developers may locate the source code. PHP is now available for usage in source and binary formats, with or without modifications, under the PHP License, version 3.01. Specific requirements that must be fulfilled in order to utilise PHP are also outlined in the license. The majority of these are related to general acknowledgements, copyright notices, and the usage of the PHP name.

Core PHP Language Concepts

Basic PHP programming concepts are often introduced and explained. This comprises:

  • Basic Syntax: How to construct a basic “Hello World” script, add comments, and escape to PHP.
  • Variables: The idea behind and application of PHP variables.
  • Control Structures: Using if and switch statements, as well as other looping constructs like while, do…while, for, and foreach, to implement conditional logic.
  • Functions: working with functions by reference, handling function arguments (such as variable-length lists and default values), defining and executing custom functions, and returning values. Additionally emphasised is the idea of avoiding function duplication.
  • Printing, processing (including nested arrays), counting elements, swapping keys and values, converting strings to arrays, extracting segments, eliminating duplicates, re-indexing, randomising, reversing, searching (including nested arrays), filtering, sorting (including multidimensional and nested arrays, and using custom sort functions), merging, and comparing arrays are all examples of working with arrays.
  • Include Files: External PHP files are incorporated using the include and require statements.
Index