When I run this file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello!</title>
</head>
<body>
THIS LINE IS HTML - NOT PHP!
<br>
<?php
echo("Hello, World! If you see this line, you are successfully running PHP
5.2.4 an the Apache web server.");
?>
</body>
</html>
I get:
THIS LINE IS HTML - NOT PHP!
Hello, World! If you see this line, you are successfully running PHP 5.2.4
an the Apache web server.
When I run this file (tips.txt is in the htdocs directory):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><style type="text/css"><!-
a { text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: arial, helvetica, sans-serif; font-size: 18pt; fontweight:
bold;}
h2 { font-family: arial, helvetica, sans-serif; font-size: 14pt; fontweight:
bold;}
body, td { font-family: arial, helvetica, sans-serif; font-size: 10pt; }
th { font-family: arial, helvetica, sans-serif; font-size: 11pt;
font-weight:
bold; }
//-></style>
<title>Tip of the day</title>
</head>
<body>
<center>
TRICK
TRAP
TRICK
<h1>Tip of the day</h1>
<div style = "border-color:green; border-style:groove; border-width:2px">
<?php
readfile("tips.txt");
?>
</div>
</center>
</body>
</html>
I get:
TRICK TRAP TRICK
Tip of the day
Warning: readfile("tipstxt") [function.readfile]: failed to open stream: No
such file or directory in C:\Apache2.2\htdocs\tip.php on line 25
When I run this file:
<html>
<head>
<title>Hi Jacob</title>
</head>
<body>
<h1>Hi Jacob</h1>
<h3>Demonstrates using a variable</h3>
<?php
$userName = "Jacob";
print "Hi, $userName";
?>
</body>
</html>
I get:
Parse error: syntax error, unexpected ',' in C:\Apache2.2\htdocs\hijacob.php
on line 10
I remove the ',' in print "Hi, $userName", I get:
Parse error: syntax error, unexpected T_VARIABLE in
C:\Apache2.2\htdocs\hijacob.php on line 10
Craig
>> Stay informed about: Apache 2.2.4 & PHP 5.2.4