473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Cannot display php code in test file on WAMP server

5
For the code below I only see "Hello PhP" and not the Hello World!

Expand|Select|Wrap|Line Numbers
  1. <h1>Hello PhP</h1>
  2. <?php
  3. echo "Hello World!";
  4. ?>
  5.  

This html file is in the local folder. and the index.php file inside the local folder works because I can see the WampServer Configuration page when I type http://localhost/ on my browser.

I have Windows Vista

I don't get it. Please help.
Mar 22 '10 #1
2 3332
Bentot
5
My file extension is .html so I changed it to .php and it worked. I thought it's possible to include PHP codes in html files?
Mar 23 '10 #2
Atli
5,058 Expert 4TB
Hey.

Technically it is possible, but it is not by default. PHP code needs to be executed by the PHP interpreter. Your HTTP server (Apache, in case of WAMP) is configured to only execute certain types of files as PHP code. These are usually just the .php extensions. Normal .html files are just sent as ordinary, non-php HTML files, but you can tell your server to execute any file as PHP code.

Everything inside a .php file, except text within <?php ... ?> tags, is considered HTML by the server (by default). So if you rename a .html file to .php you will see no difference at first. - The only difference is that now the file is run through the PHP interpreter, which will look for <?php ... ?> tags and execute them as PHP code. - Everything outside <?php ... ?> tags, and all the output generated by the code inside the tags, is sent to the browser as HTML. - The browser does not see any difference between a normal .html file and a .php file. It's all just HTML from it's perspective.

Hope that helps :)
Mar 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: crist135 | last post by:
Hi guys, I have successfully done the retrieving of PDF file from Sql Server BLOB. Though, some of the pdf files are displaying it nicely but in some, postscript is being displayed. I am using...
2
by: Gandalf | last post by:
I can't surf my wamp server , Although both of the services seems to be working. When I trying to surf my server the browser loading the page for eternity. thanking you in advance
0
by: diegososa | last post by:
Hi! I'm new here and also new in Python, and i have a simple question: I have: -a python program running on a Linux machine -a Windows XP machine with a WAMP Server, and python for Windows...
1
by: fatalparadox | last post by:
I had WAMP Server installed for a few months, everything was fine. Now all of a sudden it stopped working. It still executes the PHP but it doesn't allow me to write to a .txt file anymore. When...
6
by: praveenkhade | last post by:
I am trying to open the Enterprise manager(sqlserver 2005) but following error is showing "mmc cannot open the selected file". yesterday it was working properly but since morning its not properly...
2
by: robin1983 | last post by:
Hi All, I am facing a problem with WAMP. I installed the wamp5_1.7.1a. After installation, when I try to run the through explorer by writing "http://localhost" but its showing pages cannot be...
4
by: eschneider | last post by:
I get the following error when trying to browse the .asmx. I get the same thing when trying to add a reference. using .NET 2.0 There is no error message. Any ideas? Thanks,
3
by: robin1983 | last post by:
Dear All, I am facing a problem with WAMP server. i dowonload the WAMP SERVER2.0c and installed in my system. But the problem is that none of the server is running. When i try to access the...
7
by: sousou | last post by:
I have installed the wamp server correctly but when i called http://localhost/sam.php for example it didn't work it gave me (the web cannot found this page).
1
by: Louloul | last post by:
Hello I am working with a wamp program. when I load the page, it displays this sentence " Internet Explorer cannot display the webpage ". Here is the code <?php session_start(); ?>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.