PDA

View Full Version : Print PHP variable to screen.


Jwoody
06-06-2008, 01:29 PM
Hey, this is my first attempt at any kind of vB mod, and im just wondering how you print a php variable created, to screen? (say, within the meta description tag - the variable has been declared within showthread.php)

Cheers in advance!

Marco van Herwaarden
06-06-2008, 02:16 PM
Depending on the location etc, you could use:
- Simply add the variable somewhere in a template that is shown on the page.
- Use the PHP 'echo' comand (might not work on all locations within vBulletin or breaks the default page output, so only really usefull for debugging).

Jwoody
06-06-2008, 08:33 PM
Depending on the location etc, you could use:
- Simply add the variable somewhere in a template that is shown on the page.
- Use the PHP 'echo' comand (might not work on all locations within vBulletin or breaks the default page output, so only really usefull for debugging).

Basically, i've defined a variable within showthread.php, and wish to print it within the postbit_legacy template.

But it doesn't look like you can just place the variable (for state of example, my varible is called $myvar straight into the template and expect it to be printed; do you have to do something to the variable declared within the showthread.php file first?

Opserty
06-06-2008, 08:36 PM
In the postbit you will probably have to use $GLOBALS[yourvar] as the postbit template is evaluated within a function. Typically you can just insert the variable ($yourvar) straight into the template.

Trial and error is sometimes the best way to just figure things out. ;)