Please visit : Part 1 to learn from beginning.
Now let's continue for other writing rule of PHP. But don't forget to run these code into your browser ok? So you can see what's the result like.
5. Case Sensitive
<?php$a = 10;$A = 15;
echo "a = $A";?>
The above code tell us that the $a and $A is different, so take care when you will code, the variable name must be precise.
6. Writing in Form Element
We can use php to help us while we are facing the element form. Take a look at this example :
<html>
<head>
<title>Using PHP in element form</title>
</head>
<body>
<?php
$a = 15;
$b = 10;
$times = $a*$b;
?>
Here are some example of form and how we use the php inside it.
<form>
<input type="text" id="text1" value="<?php echo "$times"; ?>"/>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
Later, in real implementation of PHP in form, the PHP will work on every input type that we've created it in form. The PHP code will go for logic side and processing the variable in the server side. Later we will learn about PHP in form.
7. Writing PHP inside the HTML and otherwise.
In the real implementation, we will combine html and php. Not only two of that, we can combine Javascript, css, and many more of web programming language inside our web code. So now, we will learn how to write PHP inside the HTML and otherwise.
Take a look at these code :
<html>This will display "Display this!!!" 5 times in your browser. As you see, in the red one, it's the code to make looping as we now it's code "for", but look at the end of code in red one, there are'nt any closing statement ( } ). The closing statement are placed in the blue one. So between the red and blue, is the HTML code, and otherwise, blue and red are PHP code. You get it,right?
<head>
<title>Using PHP inside the HTML (Looping Code)</title>
</head>
<body>
Here are some example : <br>
<?php for ($i=1; $i <= 5; $i++) { ?>
Display this!!! <br>
<?php } ?>
</body>
</html>
That's all the Rule of writing PHP. So far you get another knowledge about PHP right?
Please check my blog for other post!
See you :)
No comments:
Post a Comment