www.xbdev.net
xbdev - software development
Monday May 13, 2024
home | contact | Support | PHP... a powerful, flexible, fully supported, battle tested server side language ..

     
 

PHP...

a powerful, flexible, fully supported, battle tested server side language ..

 


PHP > Hello 'PHP' World


Yes, YES! PHP is the nuts nut! PHP (Hypertext Preprocessor) is a scripting language primarily used for web development, so you can't just run it locally in your web page. You need to run it on a server! The web server processes the code and sends it to the web browser.

Don't be too stressed if you don't have your own server, you can run a PHP server on your local machine. One such example is XAMP, it's free and easy to install - just a few clicks and you've got PHP running on your local machine. You open a webpage and it's all good to go :D

People are still using PHP as it's great for creating dynamic web pages with embedded HTML. It is known for its simplicity, ease of integration with databases, and widespread support in the web development community.


Minimal working PHP example with comments and explanations



Text file with a '.php' extension, e.g., hello.php, then you've put the following contents:

< ?php
// This is a simple PHP script example '//' is a comment to ingore this line

// Declare a variable and assign a value to it
$message "Hello, Juicy Exciting PHP World!";

// Use the echo statement to output the value of the variable
echo $message;

// You can also use print as an alternative to echo
// print $message;

// PHP scripts must end with the closing tag
? >


What's happenining? Here's the details:



< ?php
This is the opening tag that signifies the beginning of a PHP script.

//
This is a simple PHP script: This is a single-line comment. Comments are for human readability and are ignored by the PHP interpreter.

$message = "Hello, PHP World!";
This line declares a variable named $message and assigns the string "Hello, PHP World!" to it.

echo $message;
The echo statement is used to output the value of the variable $message to the browser.

// print $message;
This is a commented-out alternative to echo. You can use either echo or print to output data.

? >
This is the closing tag that marks the end of the PHP script.



To run this script, save it with a '.php' file extension (e.g., hello.php) and place it in a directory accessible by a web server with PHP support. Open the script in a web browser, and you should see "Hello, Juicy Exciting PHP World!" displayed on the page.


The purpose of this example is a springboard! To actually get PHP running, most of the initial work is seting up your server configuration, finding where to put the files, an editor etc - then you run it and it work or doesn't.


Remember, if you forget the 'arrow' bracket, it won't work. One of the great things is you're able to mix 'php' with 'html'!! So if you don't want to use php functions/syntax you don't have to. Of course, you need to put your php code in a '.php' files for it to work.













 
Advert (Support Website)

 
 Visitor:
Copyright (c) 2002-2024 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.