What is "php"
PHP (a recursive acronym for PHP: Hypertext Preprocessor) is an interpreted, free language, originally used only for the development of applications present and active on the server side, capable of generating dynamic content in the World Wide Web.
It is among the first languages that can be inserted into HTML documents to add processing before sending to the client (browser), dispensing in many cases the use of external files for eventual data processing.
For a quick start with PHP, you can use one of these apps, which include the Apache web-server and PHP in addition to other components:
(all in English)
To test PHP online quickly, without the need to install a server on your computer or to add examples in questions or answers, you can use one of these sites:
- PHP Sandbox
- PHPTESTER
- Phpfiddle
- 3v4l.org - This site provides several versions of php for testing including a 4.
- Tutorialspoint
- Write PHP Online
Community
PHP has many active community forums, including (in English):
- Chat room Stack Overflow PHP
- Geeknet
- Linux Fund
- PHP Meetup
- Freenode IRC channel ## php
More information
On-line documentation
The PHP manual is the official documentation for the syntax of the language, with function and URL shortcut search (for example http://php.net/explode). The API is well documented for native and additional extensions. Most additional extensions can be found in PECL. The repository PEAR contains a multitude of available community classes.
Learning Resources
Where to learn more about PHP.
Books
[Iniciante]
Web development with PHP and Mysql[Intermediario]
Developing Websites with PHP[Avançado]
PHP for those who know PHP[Avançado]
PHP: Programming with Object Orientation
Tutorials
Security information related to PHP
Free Programming Books
- PHP Essentials
- Practical PHP Programming (wiki containing O'Reilly’s PHP In a Nutshell)
- Symfony2
- Zend Framework: Survive the Deep End
- PHP: The Right Way (is a quick reference organized by the PHP community for the best coding practices and accepted standards)
Frameworks
A framework, in software development, is an abstraction that unites common codes between various software projects, providing a generic functionality. (read more Wikipedia)
Full-stack
Microframeworks
- Respect (brazilian project)
- Slim
- Silex (In maintenance mode. With its order set for June 2018)
- Inphinit
- Lumen
Ides and editors
They offer a number of features to make life easier for the programmer, such as Highlight syntax, auto complete, snippet generator etc. Wikipedia brings together a list with several options, the best known are:
Free
Paid
For a comparison of some available IDE’s, read this article
Common problems
- Blank canvas
If for some reason while running your PHP code returns a blank screen, this is a sign that the error messages are being hidden. It is possible to enable them in two ways:
1 - In the archive php.ini
(if you have access) look for the lines:
display_errors = Off # linha da configuração responsável por controlar a exibição dos erros.
And change to:
display_errors = On
And also the line:
error_reporting # responsável por definir quais o tipos de erros que serão exibidos.
And change the line to:
error_reporting = E_ALL | E_STRICT
E_ALL and E_STRICT are predefined constants. More details on Predefined constants
2 - Via code, add these two lines at the beginning of the file:
ini_set('display_errors', true);
error_reporting(E_ALL | E_STRICT);
More details on: error_reporting and display_errors
- Problem with mysql extension_
The mysql_* functions have been obsolete for quite some time, officially since PHP 5.5, and have been designed for mysql 4. It is necessary to use the mysqli or PDO in its place since PHP 7, so it is recommended to use these alternatives even in versions prior to PHP 7.
Why should we not use mysql type functions_*?
Mysqli vs PDO - which is the most recommended to use?
- Source code is displayed as text instead of running
This happens when open_short_tag <?
is disabled in php.ini
, to avoid this problem use this tag <?php
to open code blocks.
There are user reports that this happens when the file has been corrupted.
- Cannot Modify header information - headers already sent by
Quite common error, in short is caused by an improper text output. For explanations and how to resolve this error see: