Author: Saim Khalid
-
Constants
A constant in PHP is a name or an identifier for a simple value. A constant value cannot change during the execution of the PHP script. It basically improves code readability and maintainability. Constants make it easier to manage the configuration settings. They make code easier to read and prevent key values from changing. Constants…
-
$ and $$ Variables
PHP is a powerful scripting language created specifically for web development. One of its unique features is the use of variables. Variables in PHP begin with the dollar symbol ($). But there is another type of variable known as a $$ (double dollar sign) variable, which is a variable within itself. In this chapter, we…
-
var dump Function
The PHP Variable Handling var_dump() function is used to display structured information such as type and the value of one or more expressions given as arguments to this function. This function returns all the public, private and protected properties of the objects in the output. The dump information about arrays and objects is properly indented to show…
-
Echo and Print
PHP uses the echo and print statements to display output in the browser or the PHP console. Both are language structures rather than functions, indicating that they are part of the PHP language. As a result, using parentheses is optional. These instructions are commonly used to display text, numbers, variables and even HTML content directly on a website. While…
-
Variables
Variables in PHP are used to store data that can be accessed and modified across the program. A variable can store a wide range of values, like numbers, text, arrays and even objects. One of PHP’s unique features is that it is a loosely typed language, which means you are not required to declare the…
-
Comments
A comment in any computer program (such as a PHP program) is a certain explanatory text that is ignored by the language compiler/interpreter. Its purpose is to help the user understand the logic used in the program algorithm. Although placing comments in the code is not essential, it is a highly recommended practice. The comments…
-
Hello World
Conventionally, learners write a “Hello World” program as their first program when learning a new language or a framework. The objective is to verify if the software to be used has been installed correctly and is working as expected. To run a Hello World program in PHP, you should have installed the Apache server along…
-
Syntax
The syntax rules of PHP are very similar to C Language. PHP is a server side scripting language. A PHP code is stored as a text file with “.php” extension. A ‘.php’ file is essentially a web page with one or more blocks of PHP code interspersed in the HTML script. However, it should be…
-
Features
PHP (Hypertext Preprocessor) is an open-source server-side scripting language primarily used for web development. PHP can be embedded into HTML code. PHP is mainly used for server-side scripting, which runs scripts on the web server and then forwards the HTML they process to the web browser on the client. This makes it possible for programmers…
-
History
PHP started out as a small open-source project that evolved gradually as more and more people found out how useful it was. Rasmus Lerdorf released the first version of PHP way back in 1994. At that time, PHP stood for Personal Home Page, as he used it to maintain his personal homepage. Later on, he…