PHP Beginner Example: Variables and Echo Output
This Snippet is coded by a user inOnline php Compiler. You can see and run this code too.
زبان: PHP
This PHP script demonstrates the basic syntax for declaring variables and outputting their values. It is ideal for beginners who are just starting to learn PHP.
- Defines a string variable $txt with the value 'Hello world!'
- Defines an integer variable $x with value 5
- Defines a float variable $y with value 10.5
- Uses the echo statement to print each variable followed by a newline character (\n)
To use this code, save it as a .php file and run it on a PHP-enabled server or CLI. You should see each variable printed on a separate line.