JV’s Power Tips for PHP (1) - Accessing Other Variables from Within this Type of Template (Page 5 of 7 )
Of course not all PHP variables come in the form of $basic_var. So how can we access more complex variables such as associative arrays, objects, cookies and variables submitted by forms within our templates? Here’s how:
Variables posted via a forms
Simply wrap the standard variable access syntax within {}’s like so:
You can also use object syntax within PHP print statements (and while assigning variables). I prefer using objects to arrays for this type of thing and often create objects on the fly to use in templates and dynamic output. Here’s how:
<?php
// Create an object on the fly.. $output->{‘my_turkey’} = “Gobble”; $output ->{‘my_dog’} = “Rex”;