i hav a problem

m new to php nd i started with writin my first page but whenever i start my browser i see the complete code and nt the output i need

i wrote

<html>
	<title>my php page</title>
	<body>
	<?php
		echo "hello there!";
	?>
	</body>
</html>

the output is d same text above

help me

Dani AI

Generated

Most likely reason your PHP shows as plain text is that the code never ran through a PHP interpreter. That happens when the browser opens the file directly (file://), the web server isn’t running or isn’t configured to handle .php, or the file isn’t in the server’s document root. This lines up with suggestions from and to use a packaged server, and with and pointing to URL/extension issues.

Try this quick checklist to diagnose:

  • Save the file with a .php extension (make sure Windows Explorer isn’t hiding the real extension).
  • Put the file in your web server’s document root (the folder WAMP/XAMPP or Apache uses for served files).
  • Start Apache (or the WAMP/XAMPP control panel) and open the page through your local server address (not by double-clicking the file).
  • Create a tiny test file to verify PHP is working:
<?php
phpinfo();
?>

If that shows the PHP configuration page, PHP is running.

If you installed Apache and PHP separately (you said PHP asked you to “manually configure”), Apache needs to be told to use PHP. For an Apache 2.2 + PHP 5.x Windows setup you would typically add lines like the examples below to httpd.conf (adjust paths to your install):

LoadModule php5_module "C:/php/php5apache2_2.dll"
PHPIniDir "C:/php"
AddHandler application/x-httpd-php .php

After editing, restart Apache.

Other tips: enable the MySQL extension in php.ini (extension=php_mysql.dll or use mysqli/PDO) if you need MySQL access; check Apache/PHP error logs for clues; restart the server after any change; save files without a UTF-8 BOM. If you want the easiest, packaged stacks (WAMP/XAMPP) handle all this automatically as and suggested.

Recommended Answers

All 8 Replies

you need a web server.
for learning google xampp or wamp

Your probably not previewing the file via through the server. What testing server are you using? Make sure your url is something like with http://localhost/filename.php. Where filename.php is your file. Also make sure the file is saved in your htdocs folder.

Goto sourceforge.net and get the DevPHP IDE package, will give you a LocalHost server you can run your script on as part of the package, code highlighting, context help


i hav wamp5

i dnt knw....m writin d url correctly....

what extension have you given the file
/myfirstfile.php ? .txt .src .html may not parse

i downloaded apache http server 2.2, php 5 and mysql server 6.0...... dere occured a problem in php5 sayin dat manually configure ur server...bt i really dnt knw how to do that...

nd one more thing i need a connector for php and mysql

d links on d google site r broken

plz help out

you might run this program directly from the browser, you need to have some web server, just install WAMP or XAMPP on your PC, if you are windows user

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.