PHP - it is a general purpose programming language used to develop a website or web application. It is a server-side scripting language embedded in HTML for developing static website, dynamic website, or web applications. It was created by Rasmus Lerdorf in 1994.
PHP - is an acronym for Hypertext Preprocessor and was previously abbreviated as Personal Home Page.
The old PHP name was Personal Home.
- It is a server-side scripting language used to develop dynamic websites or web applications.
- It is receives data from forms to create dynamic page content.
- It can work with databases, sessions, send and receive cookies, send emails, etc.
- It can be used to add, delete, change the content in the database.
- It can be used to set the restriction of user access to the web page.
PEAR - it is a framework and distribution system for reusable PHP components. It stands for PHP Extension and Application Repository. It contains PHP snippets and a library to root the code. It provides a command line interface for installing packages.
- Dynamic website:web pages are returned from a server that is processed at runtime, which means they are not pre-built web pages, but are created at runtime according to user requirements using server-side scripting languages such as PHP, Node.js. , ASP.NET, and more is supported by the server.
PHP code always starts with
Use the following steps to run a PHP program with command line:
- Open a terminal or command prompt window.
- Go to the specified folder or directory where the PHP files are present.
- Then we can run the PHP code, using the command
- Start the server to check the php code using the command
php -S localhost: port -t your_folder /
There are two methods echoand print to display text.
No, PHP is partially case sensitive. This means that variable names are case sensitive,and function names are case insensitive,i.e. user-defined functions are not case sensitive.
PHP 5 contains many additional OOP features (Object Oriented Programming).
Variables in the program are used to store some values or data that can later be used in the program. PHP has its own way of declaring and storing variables. Variable characteristics are listed below:
- A variable declared in PHP must begin with a dollar sign ($) followed by the variable name.
- The variable name contains alphanumeric characters and underscores ( i.e. ’ az ’, ’ AZ ’, ’ 0-9 ’ and ’ _ ’) in their name.
- Variable names must start with a letter or underscore, not a number.
- PHP is a loosely typed language and we do not need to declare the data types of variables, rather PHP accepts this automatically when it parses the values.
- PHP variables are case sensitive, i.e. $sum and $SUM are handled differently.
The define() function is used to create and get the value of a constant. PHP Constant - it is an identifier whose value cannot be changed over time (for example, the domain name of a website, for example, www.engineerforengineer.org). Once you define a constant, it can never be changed or undefined. The $symbol is not used with a constant.
- WordPress:WordPress - it is a free open source platform (CMS). It is the most widely used CMS in recent times.
- Joomla:It is a free open source content management system (CMS) for distributing web content. This follows the model-view-controller web application structure that can be used independently.
- Magento:is an open source and e-commerce platform for developing online businesses.
- Drupal:is a Content Management System (CMS) platform developed in PHP and released under the GNU General Public License.
- break:The break statement immediately ends the entire iteration of the loop, and program control resumes with the next statement following loop.
- continue:The continue statement skips the current iteration and continues the next iteration earlier. Continuation 2 acts as a terminator for case case and skips the current loop iteration.
- Zend Framework
Comments are used to prevent a statement from being executed. This is ignored by the compiler. There are two types of comments in PHP: single line comments and multiline comments.
- Single line comments:comments start with a double slash (//).
- Multi-line comment:comments are enclosed in / * comment section * /
The PHP count() function is used to count the number of elements in an array. The function can return 0 for a variable that has been set to an empty array. Also, for a variable that is not set, the function returns 0.
PHP supports four different types of for loop, which are listed below:
- for loop
- while loop
- action loop
- foreach loop
- The for loop is considered open to iterate, while the foreach hides the iteration and is noticeably simplified.
- The performance of the foreach loop is considered better than the for loop.
- The foreach loop, although it iterates an array of elements, execution is simplified and completes in less time than a for loop.
- The foreach loop allocates temporary memory for index iterations, which makes the system as a whole performance overkill in terms of memory allocation.