- PHP stands for PHP: Hypertext Preprocessor
- PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages.
- It is one of the first developed server-side scripting languages to be embedded into an HTML source document rather than calling an external file to process data.
- The code is interpreted by a Web server with a PHP processor module which generates the resulting Web page.
- It also has evolved to include a command-line interface capability and can be used in standalone graphical applications
- PHP was originally created by Rasmus Lerdorf in 1995.
- The main implementation of PHP is now produced by The PHP Group and serves as the formal reference to the PHP language.
Usage
- PHP is a general-purpose scripting language that is especially suited to server-side web development where PHP generally runs on a web server.
- Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on Web sites or elsewhere.
- It can also be used for command-line scripting and client-side graphical user interface (GUI) applications.
- It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use.
Data types
- PHP stores whole numbers in a platform-dependent range, either a 64-bit or 32-bit signed integer equivalent to the C-language long type.
- Unsigned integers are converted to signed values in certain situations; this behavior is different from other programming languages
- The null data type represents a variable that has no value. The only value in the null data type is NULL.
Compilers
- The PHP language was originally implemented as an interpreter.
- Several compilers have been developed which decouple the PHP language from the interpreter.
- Advantages of compilation include better execution speed, static analysis, and improved interoperability with code written in other languages.
Basic PHP Syntax
- A PHP script always starts with <?php and ends with ?>. A PHP script can be placed anywhere in the document.
- On servers with shorthand-support, you can start a PHP script with <? and end with ?>.
- For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.
- A PHP file must have a .php extension.
- A PHP file normally contains HTML tags, and some PHP scripting code.
- Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.
“Hello
world” example program
<html>
<body>
<?php
echo "Hello World";
?> </body>
</html>
<body>
<?php
echo "Hello World";
?> </body>
</html>
In the
example above the output will be Hello world.
To run php file
- If your server supports PHP you don't need to do anything.
- Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.
- However, if your server does not support PHP, you must install PHP.
No comments:
Post a Comment