PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Because we i do that and echo magic_array; it just ouputs "magic_array" and not the text Array like normal, or if i do a print_r on it it does the same thing. So is what I doing "legal" in php ?
thanks, i can serialize it and get it to define, but when I try to get it back to an array i get not defined, but i can ouput the serialized defined code before this.... heres my code:
<?php
// On an included page:
$array_to_define = array(array("1","a"),array("2","b"));
$array_to_define = serialize($array_to_define);
define('magic_array',$array_to_define);
// No error messages or any problems so far
// On page that included the above... (YES the page is included and I am sure of it)
if(defined(magic_array)){
$output = unserialize(magic_array);
print_r( $output);
} else {
echo "not defined";
}
?>
I get back "not defined" not the print_r of the array.... but if i remove the rest of the second part code expect for the unserialize and print_r it works fine.... why?