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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho