The PHP script is used to make a website dynamic.
The code is written within the defined PHP tags otherwise it would not execute.
With tags, you can display the final output after data manipulation e.g. listing fetch records from MySQL database in the <table>, display value in HTML element, upload image, etc.
Syntax –
Syntax – include
include "file-path";
Syntax – require
require "file-path";
Both statement use for including file but only difference is –
The require statement trigger FATAL ERROR if a file included more than once but the include statement doesn’t.
Example
With tags, you can display the final output after data manipulation e.g. listing fetch records from MySQL database in the <table>, display value in HTML element, upload image, etc.
Contents
1. PHP Tags
All PHP codes are specified within<?php ?>
tag.Syntax –
<?php // code ?>Example
<html> <body> <?php echo "PHP CODE"; ?> </body> </html>
2. Include and require
With include and require statement, you can include existing files in your file.Syntax – include
include "file-path";
Syntax – require
require "file-path";
Both statement use for including file but only difference is –
The require statement trigger FATAL ERROR if a file included more than once but the include statement doesn’t.
Example
<?php include "config.php"; ?> <html> <body> <?php echo "PHP CODE"; ?> </body> </html>
3. Conclusion
Specify your PHP code between<?php ?>
tags in the webpage. You can use include and require statement to embed existing files.
0 Comments:
Post a Comment