wolfrock Posted November 28, 2006 Share Posted November 28, 2006 I've been working with multiple different pages (.php) that all utilize universal navigation and footer .php files, since those are essentially the same for every page on the site.I'm trying to define a simple numeric variable within the content of the main / top part of the page(s) (basically one variable that will be different from page to page), and then recall/print that variable within the "footer" section that's included on the bottom (a separate PHP file). This seemed to work OK using the most basic variable commands when I was testing the site on my computer, but after uploading to a server, the basic commands for defining & printing a php variable don't seem to be doing the trick.Any advice is greatly appreciated... just trying to get a numeric variable to be defined in a .php file, but recalled further down the page in a separate footer.php.Thanks a lot! 8) Link to comment https://forums.phpfreaks.com/topic/28747-n00b-php-variable-question-recallingprinting-in-separate-footerphp/ Share on other sites More sharing options...
jwadenpfuhl Posted November 28, 2006 Share Posted November 28, 2006 maybe post some of your code to give a clearer example of what you're looking for. I'm having trouble picturing what you're asking... Link to comment https://forums.phpfreaks.com/topic/28747-n00b-php-variable-question-recallingprinting-in-separate-footerphp/#findComment-131590 Share on other sites More sharing options...
The Little Guy Posted November 28, 2006 Share Posted November 28, 2006 You would call the variable the same way you would if it were in the same file, when you include a file, it basically turns two page into one, and every time youadd another file the one larger file and the next added file become one file, and this process continues until it gets to the very bottom of all the files. Link to comment https://forums.phpfreaks.com/topic/28747-n00b-php-variable-question-recallingprinting-in-separate-footerphp/#findComment-131596 Share on other sites More sharing options...
wolfrock Posted November 28, 2006 Author Share Posted November 28, 2006 Now that I think about it, the variable would only need to be text and not numeric (no actual calculations being done with it), just happens to be a number in this case.Here is an example of the code I'm using, really basic stuff.Within the individual pages:<body><?php$restockfee = "6.00";?>...then the content for the rest of the page like images, text, etc.at the bottom of the page, my universal 'footer.php' file is included:<?php @include("http://mywebsite2.com/global/footer.php") ?> <--- just an example</div></body></html>within that footer.php, I'm attempting to display '$restockfee' in a text paragraph using this code:<p>the restocking fee for this item would be <?php print $restockfee; ?>.</p>Like LittleGuy said, shouldn't the footer.php just become part of the page's code after it's included and the variable carry over from the top of the page? The variable is displaying o.k. when I preview the working file in dreamweaver, but doesn't show up when I upload the .php files to a server and test it out. Is there a different way I can globally define the variable so that it carries over to the footer.php and is recalled without any problems?Maybe the problem lies in that the individual pages are being hosted on one server (mywebsite1.com, for instance) and the global elements (style sheets and stuff, but most importantly that 'footer.php' I'm using) are hosted on a second server (mywebsite2.com) perhaps creating a problem with the continuity of the php and the variable carrying over properly... or wouldn't that make a difference at all?thanks again! Link to comment https://forums.phpfreaks.com/topic/28747-n00b-php-variable-question-recallingprinting-in-separate-footerphp/#findComment-131620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.