TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

PHP

PHP Script Syntax

Overview

In this tutorial, we will learn PHP Script Syntax in HTML documents. We can embed PHP Script into standard HTML web pages.

PHP Script Syntax

PHP script starts with <?php and ends with ?>.

<?php
?>

We can also use <? to start and ?> to end the PHP script.

<?
?>

Example

<!DOCTYPE html>
<!–
PHP Script Syntax Demo
–>
<html>
<head>
<meta charset=”UTF-8″>
<title></title>
</head>
<body>
<?php
//Sample PHP Code
echo “Hello, This page can run PHP code!”;
?>
<h1>PHP Tutorials </h1>
<h3>www.TestingDocs.com</h3>
</body>
</html>

Sample Output

Save PHP file with a “.php” file extension. For example, This tutorial uses “test.php”. PHP file should be deployed to the server in order to run. The exact path may vary from server to server. On Apache web server it is usually the htdocs folder. Deploy the file to the folder.

 

PHP Script Syntax

 

We can access the file from the web browser by typing the URL in the address bar.

http://localhost/test.php

The string localhost refers to the server running on your own machine. We can also refer to the local server is by using the loopback IP address: 127.0.0.1

http://127.0.01/test.php

The server runs on the default HTTP port 80. Incase the server runs on a different port we can append the port to the address. For example, if the server runs on 8080 port, we can access the URL as:

http://localhost:8080/test.php

—

PHP Tutorials

PHP Tutorials on this website:

https://www.testingdocs.com/php-tutorials/

More Information on PHP

https://www.php.net/

Related Posts

Compoer Command line command

PHP /

Install Slim Framework on Windows

php download website

PHP /

Download and Install PHP on Windows

Composer Install Windows

PHP /

Composer Download on Windows

Apache conf file

PHP /

PHP 7 Configuration in Apache Server

testing php linux

PHP /

Testing PHP with Apache Server on Linux

‹ Getting Started with PHP› PHP Comments

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version