deane Posted December 4, 2008 Share Posted December 4, 2008 Hi guys, I'm new here, and I'm also new at php. I'm teaching myself really, and there are a lot of things that I don't understand yet. My current problem is the following code: <html> <head><title>Print 10 Times</title></head> <body <?php $string = "Look, I'm red then I'm blue!"; // use FOR loop to print the value of $string 10 times for($i = 1; $i <= 10; $i++) echo "<h1>$string</h1>"; ?> </body> </html> The problem is the echo line (in bold). The first string printed is not the size of h1 while the rest are all in h1. However, if I change it like this echo "<h1><h1>$string</h1><h1>"; then all of them become h1. Why is this? Why do I need 2 <h1> tags? Thanks for your help on this fellas. I'll probably post some more when I hit roadblocks like this during my PHP self-teaching experience. BTW, I'm using WAMP on my PC. Quote Link to comment https://forums.phpfreaks.com/topic/135449-solved-beginner-problem-with-echo/ Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 Not really a php issue. You are missing the end > on the <body tag. Add that and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/135449-solved-beginner-problem-with-echo/#findComment-705655 Share on other sites More sharing options...
deane Posted December 4, 2008 Author Share Posted December 4, 2008 OMG lol, I lost sleep over this. Thanks for clearing that up. I guess being a programmer requires a keen eye Quote Link to comment https://forums.phpfreaks.com/topic/135449-solved-beginner-problem-with-echo/#findComment-705658 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 OMG lol, I lost sleep over this. Thanks for clearing that up. I guess being a programmer requires a keen eye It happens to everyone. Just as you get more advanced the stupider the answer is...seriously. It is always the small little stupid thing that makes a script go bad. I've spent countless hours on a problem and the solution ended up being something that was soo simple I should have saw it first. But yea, it still happens to me. Quote Link to comment https://forums.phpfreaks.com/topic/135449-solved-beginner-problem-with-echo/#findComment-705659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.