how to do php code example

Example 1: how to use php

// Firstly you must have PHP installed & running a web server
// This could be Apache, Nginx, etc...
// Or for quick testing purposes and for the purpose
// of this example, you could run
// PHP's own dev server from a shell
php -S 127.0.0.1:8080 -t your-web-directory-location
// This will start a web server on localhost port 8080
// The -t switch sets the document root, this is where your
// home page, typically index.php will be situated

// very basic index.php example
<?php
	echo "Hello, world!";   
?>
  
// You can now go to a browser and enter 127.0.0.1:8080
// You will presented with your simple web page
// Hello, world!

Example 2: what php can do

PHP can generate dynamic page content.
PHP can create, open, read, write, delete, and close files on the server.
PHP can collect form data.
PHP can send and receive cookies.
PHP can add, delete, modify data in your database.
PHP can be used to control user-access.
PHP can encrypt data and apply validation.
PHP used to send and receive E-Mails.
PHP can be used to integrate with other third party tools.
PHP can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.

Example 3: ?? php

?: // !empty()
?? // isset()

Tags:

Php Example