Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
Help passing variables

Posted by PhpNewbie (PhpNewbie), 30 August 2004
Hi people !

Well I tried about everything, and nothing works

I don't want to use classes, just the standard php available on my server..

Here is what I'm "trying" to do

--------php file----- (Called test.php)
Code:
<?php
$message = "Test";
include "test.tpl";
?>

--------php file-----


--------html file----- (Called test.tpl)
Code:
<html>
<head>
</head>
<body>
{message}
</body>
</html>

--------html file-----

simple ? so why wont the variable pass ?

Posted by bschultz (bschultz), 31 August 2004
Try something like this:

Code:
<?php  
$message = "Test";
?>  



and this:

Code:
<html>
<head>
</head>
<body>
<?php
include "test.php";
echo $message;
?>
</body>
</html>


And, both files will need to have the php extension this way.

Let me know if I'm not following what you are doing.

Brian


Posted by PhpNewbie (PhpNewbie), 4 September 2004
Thanks for the reply..

I would like a PHP file to display its output in a html file as shown above.

So the includes is the html file used to display

Just like the template system of phPBB

Posted by admin (Graham Ellis), 5 September 2004
Hi ...

In your original post replace
  (message)
with
  <?php echo ($message); ?>
And I think that fixes your immediate problem.

Brian's example works the other way - it embeds PHP into HTML.  Which way do you want it to work and I'll come up with another example / explain a bit further.  Do you want the file names in the URL to be essientially an HTML page with some extras, or a PHP script that calls in HTML?

Posted by PhpNewbie (PhpNewbie), 6 September 2004
<?php  
$message = "Test";
include "test.tpl";
?>  

This will now load and display the html file called test.tpl, and inside that test.tpl I have the output "$message" as in above

{message}

Which wont work

<?php echo ($message); ?>

Its not a php file, the output is html, php wont display that unless the file was run as php, works fine if I include it in the test.php but I want it in the html

Clear as mud

php file loads and displays the html file, and the html file is the one that I want to display the output in

{message} dont work its not passing it

Posted by PhpNewbie (PhpNewbie), 6 September 2004
Ok, have it sorted
test.tpl
Code:
<html>
<head>
</head>
<body>
<?php echo $message ?>
</body>
</html>


Graham Ellis, sorry never understood you



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho