Set up Apache to read php IN html code?
Hi guys,
I know a reasonable amount about Apache, but am no expert. Have a question for you. My Apache server is running on linux. All of my pages on my site are .html extensions (except for a few .php pages. Recently, I started learning php. One thing I tried was to put php code INTO html. When I did this and tried to view the site, the php code would actually show up ON the site in the browser. I have been told that: Quote:
Chris |
gee i didn't think u had to do anything, unlike perl.
So does php work at all, do pages with .php extentions work. if so inline php should work as well. but u cannot just start coding u have to encapsulate it eg <?php echo "Hello World<P>"; ?> |
what does
<? phpinfo(); ?> show? i.e create a html file and put the above code in it. then name the file index.php and stick it in your apache root. you should see tones of info about your php system. if not php aint working! |
Thanks for the replies, guys. I DO see pages ending in .php, and I know php is installed and working correctly. What's NOT working is when I have an html page with php code IN the html code. When that happens, the php code is displayed on the page itself. The only advice I've been able to find is what I quoted in my original post.
What I mean is this: Quote:
Chris |
can u put
<body> <?php echo "Hello World<P>"; ?> </body> into a file called test.html what does it do |
Hello again.
If I do that, it shows all the code in the browser itself. I attached a screenshot for you to see. If I then change the filename to "test.php", though, it displays only "Hello World" as it should. http://www.bartlett-family.net/quiz/image1.jpg The file itself is here. The same file (but with a php extension) is here. Chris |
In addition, I've been reading up on this. I already added:
Code:
AddType application/x-httpd-php .php .html Code:
ScriptAlias /cgi-bin/ "/blah/blah/blah/cgi-bin/" Chris |
You could have a html file ending in .php and if no php code was in it then the file would be ouputed as is. if the html file had <?php ?> then what ever is in those brackets will be passed to the php pasher where the code would be interupted.
|
Quote:
|
as far as i know any html file that contains php data has to end in .php in order to be pased to the php parser and outputed.
getting php code outputed correctly and still retaining the .html extension isnt possible i didnt think. |
Quote:
Code:
AddHandler php-script .php .html Chris |
All times are GMT -5. The time now is 05:10 PM. |