- A PHP script can be placed anywhere inside an HTML document. They start with the tag:
<? PHP
// PHP code is written here
?>
PHP scripts use a function called "echo" to output text as "Hello!" to a web page. Create a file, write a simple PHP expression and save with the .php extension:
<? Php
echo "Hello!";
?>
We store it in the index root folder.php in the Apache root file (In Windows, it is usually the folder
C:/xampp/htdocs). Now open the web browser and go to http://localhost/index.php
Each PHP row ends with a semicolon (;).
We can include PHP in the HTML script tag.
<Html>
<Head>
<title> My first page in PHP </title>
</ Head>
<Body>
<script language = "php">
echo "Hello!";
</Script>
</Body> </ html>
But in the latest version only tags are recommended <? PHP? >. Also, short tags can be used, as long as they are supported by the server:
For example:
<?
echo "Hello!";
?>
However, <? PHP? > as the official standard, is the way recommended for writing PHP scripts.
Echo
PHP has the "echo" construction function, which is used to output text. It is not a function; it is a construct of language. So it doesn't require snake nails.
example:
<? Php
echo "I'm learning PHP!";
?>
The text can be in double or single quotes.
PHP instructions
<? Php
echo "A";
echo "B";
echo "C";
?>
The PHP code lines end with a comma. Forgetting the endpoint will give an error. HTML tags can be added to the PHP echo function.
example:
<? Php
echo "<strong> This is a dark text. </strong>";
?>
PHP Case Sensitivity
-In PHP, all keywords (for example if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive. In the example below the three statements are the same:
<! DOCTYPE html>
<Html>
<Body>
<? Php
ECHO "Hello! <br>";
echo "Hello! <br>";
EcHo "Hello! <br>";
?>
</Body>
</Html>
<? PHP
// PHP code is written here
?>
PHP scripts use a function called "echo" to output text as "Hello!" to a web page. Create a file, write a simple PHP expression and save with the .php extension:
<? Php
echo "Hello!";
?>
We store it in the index root folder.php in the Apache root file (In Windows, it is usually the folder
C:/xampp/htdocs). Now open the web browser and go to http://localhost/index.php
Each PHP row ends with a semicolon (;).
We can include PHP in the HTML script tag.
<Html>
<Head>
<title> My first page in PHP </title>
</ Head>
<Body>
<script language = "php">
echo "Hello!";
</Script>
</Body> </ html>
But in the latest version only tags are recommended <? PHP? >. Also, short tags can be used, as long as they are supported by the server:
For example:
<?
echo "Hello!";
?>
However, <? PHP? > as the official standard, is the way recommended for writing PHP scripts.
Echo
PHP has the "echo" construction function, which is used to output text. It is not a function; it is a construct of language. So it doesn't require snake nails.
example:
<? Php
echo "I'm learning PHP!";
?>
The text can be in double or single quotes.
PHP instructions
<? Php
echo "A";
echo "B";
echo "C";
?>
The PHP code lines end with a comma. Forgetting the endpoint will give an error. HTML tags can be added to the PHP echo function.
example:
<? Php
echo "<strong> This is a dark text. </strong>";
?>
PHP Case Sensitivity
-In PHP, all keywords (for example if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive. In the example below the three statements are the same:
<! DOCTYPE html>
<Html>
<Body>
<? Php
ECHO "Hello! <br>";
echo "Hello! <br>";
EcHo "Hello! <br>";
?>
</Body>
</Html>
0 Comments
Please do not enter any spam link in the comment box.