Variable disaper

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!

Moderator: General Moderators

Post Reply
taly
Forum Newbie
Posts: 1
Joined: Thu Jan 21, 2010 3:25 am

Variable disaper

Post by taly »

In the script below I cannot figure out why my $test_array is gone after line 16

Please give me a hint to solve this problem

Code: Select all

<?php
 
$test_array = array(1,2,3,4);
 
// Here I can see the $test_array
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="testing">';
// echo "<select name='test'>";
 
print_r($test_array); Display: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 
 
echo "<br>";
echo "<br>";
 
// Here I cannot see the $test_array
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="testing">';
echo "<select name='test'>";
 
print_r($test_array); Display: Nothing
 
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Variable disaper

Post by John Cartwright »

Nothing? Are you sure it's not displayed in the source code? Considering your outputting it inside a <select> tag I doubt it would show up on screen.

If not, what does var_dump() say..
Post Reply