PHP Syntax: what is it?

· Dev & Design
Authors

Actually writing PHP on your computer is very simple.

except text editor
(like Notepad in Windows) You don’t need any specail
software. and you are ready to write your
first PHP script.


General Syntax for PHP

PHP scripts should always be enclosed in between two PHP tags. This tells the
server to parse all the information between them as PHP code. The three different
ways for this are as follows:

<?
Here is a PHP Code
?>

<?php
Here is a PHP Code
php?>

<script language=”php”>
Here is a PHP Code
</script>


Your First PHP Script

You will be writing very basic code as your first PHP script. All that it will do is,
just print out all the information about PHP on your server. Write following code in
your text editor:

<?
phpinfo();
?>

Nearly all lines are ended with a semicolon as with many other scripting and programming languages
and if you miss it you will get an error.


Finishing and Testing the PHP Script

After writing your script save it as phpinfo.php and then upload it to your server.
in the normal way. And now, using your browser, go to the URL of the script. If it has
worked (and if PHP is installed on your server) you will get a huge page containing all the
information about PHP on your server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s