Saturday, 19 October 2013

Embedding PHP Inside HTML

Embedding PHP Inside HTML
This is a tutorial i am going to talking about embedding PHP Inside HTML. Now embedding is paying something within something embedding insides. lets see example
Code for simple html form with php file extension (screenshot1):-
Embedding php Inside Html
Embedding php Inside Html (Screenshot1)
1
<input type="text" value=" Hello World.">
output (Screenshot2) :-
Embedding php Inside Html
Embedding php Inside Html (Screenshot2)
you will see a small text-box with echo hello world. Now in another example i will embedding php code with html by using variables of php and in values of html form i will use standard variable for string lets see how it will happens
Code for embedding PHP Inside Html (Screenshot3):-
Embedding php Inside Html
Embedding php Inside Html (Screenshot3)
1
2
3
4
<?php
$text = 'Hello World.';
?>
<input type="text" value="<?php echo $text; ?>">
Output (Screenshot4):-
Embedding php Inside Html
Embedding php Inside Html (Screenshot4)
In Advance php you have to use dynamic forms and so its good example for start-up  now in this $text is the variable which is string Hello world. and in html code we had called $text which is string Hello world. its pretty easy. variables also use in database , static text etc. Its very useful in php. variables are declared with ($) sign. and at end use “;”. and when you write php code u can write in one line or multiple line there is same effects. for example
you can use this code also for same result (screenshot4) :-
Embedding php Inside Html
Embedding php Inside Html (Screenshot4)
1
2
3
4
5
6
7
<?php
$text = 'hello world.';
?>
<input type="text" value="<?php
echo $text;
?>
">

No comments:

Post a Comment