Skip to main content Skip to docs navigation

PHP (a recursive initialism for PHP: Hypertext Preprocessor) is an open-source server-side scripting language that can be embedded into HTML to build web applications and dynamic websites.

On this page

PHP

Examples

Basic syntax

php
                                        
                                            // start of PHP code

                                            
                                                <?php
                                                // PHP code goes here
                                                ?>
                                            
                                            // end of PHP code

                                        
                                    

Printing data on screen

php
                                        
                                            
                                                <?php
                                                echo
                                                "Hello World!"
                                                ;
                                                ?>
                                            
                                        
                                    

PHP variables

php
                                        
                                            
                                                <?php
                                                // variables
                                                $nome
                                                =
                                                'Danilo'
                                                ;
                                                $sobrenome
                                                =
                                                'Santos'
                                                ;
                                                $pais
                                                =
                                                'Brasil'
                                                ;
                                                $email
                                                =
                                                'danilocarsan@gmail.com'
                                                ;
                                                // printing the variables
                                                echo
                                                $nome
                                                ;
                                                echo
                                                $sobrenome
                                                ;
                                                echo
                                                $pais
                                                ;
                                                echo
                                                $email
                                                ;
                                                ?>
                                            
                                        
                                    

See also

Updated on April 20, 2024 by Datarist.