PHP
PHP is a development language, based on scripts oriented Web pages
It's not a markup language like HTML could be,
XML or WML
A PHP program is executed on the server and the result sent to the browser
The result will usually generate an HTML, XML, or WML page
A being a language that runs on the server is not required that the browser supports it, but for the PHP pages work, the server are housed itself must bear
PHP history
It was originally designed in language Perl, relying on a set of binary CGIRs (a program that runs on a web server) written in the language C by the Danish-Canadian programmer Rasmus Lerdorf in 1994 to show your CV and save certain data, such as the amount of traffic your website received
On June 8, 1995, it was published under the name Personal Home Page Tools after Lerdorf combined it with its own system to process forms FI (Form Interpreter) resulting in the PHP/FI
The system Personal Home Page Tools became relatively successful because others asked Rasmus to allow them to use their programs on their own pages
Two Israeli Technion programmers, Zeev Suraski and Andi Gutmans, rewrote the parser analyzer in 1997 and created the basis of PHP 3, and changed its name to PHP (Hypertext Preprocessor)
PHP3 was officially released in June 1998
In 1999, Suraski and Gutmans rewrote the PHP code and created what is now known as engine Zend. Founding Zend Technologies in Ramat Gan, Israel
In May 2000, PHP 4 was launched using the new engine Zend 1.0.
In its version 4.1, released on December 10, 2001, the variables were introduced superglobals ($_GET, $_POST, $_SESSION, etc)
In version 4.2, released on April 22, 2002, they were disabled the register_globals by default
Data received by the network were no longer inserted in the global namespace, closing possible security holes in applications
In version 4.3, released on December 27, 2002, was introduced CLI (a command line interface), and the CGI (a common interface for data entry)
In version 4.4, released on July 11, 2005, man documentation pages were added to phpize and php-config
On 13 July 2007 announced the suspension of the support and development of version 4 of PHP
However the new version 4.4.8 was released with security enhancements, which was published on 13 January 2008 and subsequently version 4.4.9, which was published on 7 August 2008
He was given support critical bugs until 9 August 2008
On 13 July 2004, PHP 5 was released, using improved engine Zend Engine 2.0 (or Zend Engine 2)
In version 5.1, released on November 24, 2005, performance improvements were added with the introduction of compiler variables for your new PHP engine
In version 5.2, released on November 2, 2006, he was added native support for JSON (JavaScript Object type)
In version 5.3, released on June 30, 2009, he added:
- support for namespaces
- static link runtime
- tag jump (GOTO)
- native Closures
- native support for PHP files (PHAR)
- a garbage collector for circular references
- I improved support for Windows, sqlite3 and mysqlnd as replacement libmysql as the library for extensions that worked with MySQL database
- including fileinfo to replace the function mime_magic to improve support for international extensions MIME and remove the deprecated ereg
In its version 5.4, released on March 1, 2012, support was added for Trait and working with abbreviated syntax arrays
the following elements being considered deprecated removed: register_globals, safe_mode, allow_call_time_pass_reference, session_register(), session_unregister() and session_is_registered()
In version 5.5, released on June 20, 2013, new generators and function loops were added empty() supports expressions
the support was also abandoned for Windows XP and Windows Server 2003
In version 5.6, released on 20 August 2014, the constants were added with scalar expressions, argument lists of variable length and the exponential by the operator **
PHP 6 development was delayed because developers decided that the approach was to treat Unicode strings was not right, and began to try alternative forms before launching this version
All improvements that were planned for PHP 6, however, were added in PHP 5.3.0 (support for namespaces, static binding at runtime, lambda functions, closures, the GOTO label) and the 5.4.0 (traits, rebinding closures)
A final version 6 was finally abandoned in favor of 7
Version 7.0, was released on November 3, 2015, performance improvements and declaration of return types were added for functions
In version 7.1, released December 01, 2016 were added the return type null, the class visibility modifier const, the type nullable, pseudo type iterators, catching multiple types of exceptions
In version 7.2, released on 30 November 2017, he was added the new return type object and integration of Libsodium as an extension of the core
In version 7.3, released on December 6 2018, a flexible syntax was added for Nowdoc and Heredoc, support for references and deconstruction of arrays with list(), support for PCRE2, function hrtime()
Version 7.4 was released on October 28 2019 and reached end of life on November 28 2022
In version 8.0, released on October 26 2020, new features were added and performance was increased
In version 8.1, released on October 25 2021, the properties were added readonly, Enums, Fiber and new syntax
In version 8.2, released on December 8 2022, the attribute was added AllowDynamicProperties and creating dynamic properties was deprecated
PHP programming
To use PHP previously we install on our server
If you also want to use a database we can use PHP in conjunction with the lightweight database manager data Mysql
Or if you want a version that takes all, also included additional server as a mail server, a file server or Tomcat for Java interpreter, we can use the free distribution of Apache Friends, XAMPP
Once installed our server and the PHP module is active and configured, we can begin our programs written in PHP on our Web pages
In the example it has been embedded PHP code in the HTML itself, but this is not the only way in which we can include it
We can see that this simple CGI script is not equal to another written in other languages Perl or C
Instead of writing a complete program with all the necessary commands to generate HTML output directly write the HTML code with PHP code embedded (embedded) in the same HTML, which will output (in the example, produce text we want the body tag is displayed)
To include PHP code we use special tags beginning <?php and final ?> that will allow us to enter and exit Zend PHP interpreter
We can use 4 ways to exit and enter HTML to PHP interpreter:
-
using tags beginning <?php and final ?>
-
using abbreviated version of the beginning label <? and final ?>
As of PHP 7 this form is deprecated
-
using the ASP version of the beginning label <% and final %>
As of PHP 7 this form is deprecated
-
attaching to the HTML document commands as a script file
We can also directly reference a file with extension .php which we can load inside anywhere in the document HTML using the function include
However, abusing this practice can force us to copy over and over again the include function in all our HTML files
For this reason it is required to use a file index.php that generates the HTML that the browser will receive and in which only the includes that the page needs will be loaded
Separation instructions
A the same as in C or Pascal languages, statements are terminated using semicolons
The final label %> also it means the end of the sentence in the event that there is no more PHP code, so in the example are equivalent
PHP Comments
PHP supports type comments C, C++ or Shell de Unix