Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,939 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,719 people online right now. Registration is fast and FREE... Join Now!




Unexpected results from index.php

 
Reply to this topicStart new topic

Unexpected results from index.php

rylenolflu
24 May, 2008 - 09:23 AM
Post #1

New D.I.C Head
*

Joined: 23 May, 2008
Posts: 5

Hey guys so I'm just starting my PHP learning journey and I have stumbled upon a problem. I am inputting this code into my index.php file

CODE

<?php
$myString = "Hello!";
echo $myString;
echo <h5>I love using PHP!<h5>";
?>


yet when I refresh my server I get this

CODE

I love using PHP!
"; ?>


Any explanations as to why I might be getting this negative result. It should read:

Hello!

I love using PHP! in bold

** Edit ** code.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Unexpected Results From Index.php
24 May, 2008 - 09:44 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,173



Thanked: 208 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
You are missing some double quotes and such. Here would be the proper way...

CODE

<?php
$myString = "Hello!";
echo "$myString";
echo "<h5>I love using PHP!<h5>";
?>


Notice that I put on some double quotes for $myString and then you forgot to start your second echo with a double quote.

Other than that, well done. icon_up.gif
User is offlineProfile CardPM
+Quote Post

rylenolflu
RE: Unexpected Results From Index.php
24 May, 2008 - 10:11 AM
Post #3

New D.I.C Head
*

Joined: 23 May, 2008
Posts: 5

Awesome, thanks so much for your help.

Just one last question, If I am serious about learning PHP (I want to create a web based game) should I study HTML first? I know very little about HTML and have noticed that even in PHP tutorials HTML seems to find its way in there.
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Unexpected Results From Index.php
24 May, 2008 - 10:34 AM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,173



Thanked: 208 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Yes it is crucial that you know HTML. PHP is for processing and showing its results as web output... thus HTML. Master HTML because you will certainly need it since PHP and HTML go together like peanut butter and jelly.

smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:40AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month