Search code examples
phploopsquotation-marks

Quotation marks don't seem to work


I have been working on a piece of code for a webpage and my quotation marks within my php portion do not work.

I got this simple test from w3school and even then it still does not work:

Test:

<!DOCTYPE html>
<html>
<body>
<?php 
$x = 6;
do {
     echo "The number is: $x <br>";
     $x++;
} while ($x <= 5);
?>
</body>
</html>

Expected result:

The number is: 6 

The result I am getting:

"; $x++; } while ($x <= 5); ?>

It seems to be skipping one of the quotation marks and I cant figure out why.

The link to the w3school test is: http://www.w3schools.com/php/showphp.asp?filename=demo_loop_do_while2

For future reference, why has this been down voted?


Solution

  • You are opening the file in your browser like a text file or jpeg which you cannot do for dynamic web pages. You must access it via your web server by its URL. Otherwise the web server doesn't handle the file can't process the PHP.