How to write Better PHP Code

Add Tool

A Guide For Writing Better PHP Code


I will try to give basic information about Better PHP Code but it will be helpful. You can learn detailed from documentation for PHP. Let's get started with your first PHP script.

How to write Better PHP code?

You can write PHP code in a text editor or use web development software like Adobe Dreamweaver. Remain that PHP code does not active without server. Firstly you can use local server. Please learn about local server and setup it in your computer. Now create a page as heloword.php in your server directory and write the below HTML code.

<html>
<head>
<title>My PHP First code</title>
</head>
<body>
</body>
</html>

Now browse this file with a web browser with your directory link. (If you use Localhost than type http://localhost/your_directory folder name in your web browser’s address bar and press enter. You will see your created file heloword.php and if you use your remote server then visit http://www.your-domain-name/your-directory folder name.). You will see nothing because we don’t write any word in our body tag. Now try to add some PHP code in the body tag to display “This is my first PHP code practice.” Don’t afraid it is simple to display. See the below code her I have added this word “This is my first PHP code practice.

<html>
<head>
<title>My PHP First code</title>
</head>
<body>
<?php
echo "This is my first PHP code practice.";
?>
</body>
</html>

Now reload your web browser you will see our targeted sentence. If you see carefully, you will notice we add our text or sentence in our body tag with some PHP coed. Here,

<?php PHP start
echo echo or print is used to display any things in browser
" " Our words will be placed between this sign or contusion
; Use this sign at the end of line
?> PHP end

Now try to add two paragraphs using the above structure. Are you unable to add 2 paragraphs? Ok, I have given another example to add 2 paragraphs but you should try to add 3, 4 or more paragraphs. See the below structure and try yourself.

<html>
<head>
<title>My PHP First code</title>
</head>
<body>
<?php
echo "This is Paragraph-1";
echo "<br/>";
echo "This is Paragraph-2";
?>
</body>
</html>

To see the result you should follow the above instruction. Here I have used <br/> tag for line break.


Tags: php, Better PHP Code, PHP Code, php code practice, php comment, php define, high quality code, php tutorial pdf,
Payza

About Masum Billah

A Guide For Writing Better PHP Code 1stWebSuite website seo tool is a free website ranking tool site provides a lot of on page and off page seo useful tools for you. On this site, we have a large number of website ranking tools


SIGN UP TO GET UPDATE TO YOUR INBOX




Discuss about: How to write Better PHP Code


adf.ly