echoing dynamic variables[SOLVED]

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
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

echoing dynamic variables[SOLVED]

Post by raghavan20 »

The explanation is given in the comments.
I am trying to print all the variables values from h0...h4.
but this displays as
Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34


Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Notice: Undefined variable: h in /home/www/raghavan.100webcustomers.com/Sha1.class.php on line 34

Code: Select all

/* encrypt if initial conditions are met */
	if (isset($_GET["input_string"])){
		/* define initial variables */
		$h0 = "67452301";
		$h1 = "EFCDAB89";
		$h2 = "98BADCFE";
		$h3 = "10325476";
		$h4 = "C3D2E1F0";
	}
	
	for ($i = 0; $i < 5; $i++){
		echo $h{$i}. "<br />"; //-------->>This line should print values of $h0, $h1...$h4. How shd I do that???
	}
Last edited by raghavan20 on Sat Oct 08, 2005 6:33 am, edited 1 time in total.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Code: Select all

echo ${'h'.$i}. "<br />";
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

that works!!! thanks very much
Post Reply