php is widely used as web server side programing language. So most users get just in contact with the results of php (the web page) and not with the php itself.
php guides show how to use php on webservers but web servers are not easy environments to learn a new programming language
php can also be run without web server. This goes almost as with any other programming language. Create a echo.php
file
<?php echo "Hello PHP!!!!!"; ?>
The mystery here are the beginning <?php and ending lines ?>
then the program can be started as php echo.php
Without the beginning <?php and ending ?> php echoes the program as text.
An other more popular way is putting this file on a webserver capable to run php.
Then open it using a browser as http://<url>
/echo.php and therefore using the web server will echo all in the browsers window. Don't open it as file since this will bypass the web browser and not run the code.
Variables are declared as $txt = "PHP"; and then used as $txt
php can be embedded in a html file
<!DOCTYPE html> <html> <body> <h1>A PHP page</h1> <?php echo "Hello World!"; ?> </body> </html>
Global declared variables can be use in functions as
function f() { global $x, $y; $y = $x + $y; }
or via $GLOBALS['x']