|
Posted by bobzimuta on 07/24/06 22:54
Pat wrote:
> Hello,
>
> I have a question in regards to the use of php and html. The question
> is: can someone write a script separate from the html page and then call
> the script in like in a css style and use the values in the html page?
> If so how?
>
> I am just learning php and am not ignorant to programming, but I would
> use a function or created class in the separate file but how would you
> call the php file into the html file is what's killing me.
>
> I hope that makes sense and I hope someone can at least point me in the
> right direction to find the answer; because, to me putting all the code
> in an html document is redundant especially on the oop side.
>
> Thank you,
> Patrick
Easy way:
Write all your php code and require the html file
# test.php
<?php
$test = "Hi there";
require_once( 'test.html' );
exit(); // stop execution of script
?>
#test.html
<html>
<body>
<?php echo $test ?>
</body>
</html>
Little more complicated, but worth it if you want to get into
professional PHP development.
Smarty - PHP templating engine
http://smarty.php.net
1. Allows for logic in the template - Seperation of template logic and
business logic
2. Template caching
3. Many more benefits, check out the documentation
Navigation:
[Reply to this message]
|