FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Simple PHP question...





UberKnights
If I want to run even one line of PHP or PHP funtion, the page extention has to be .php ?
Just wondering
badai
yes, so that apache can ask php to interpret it.
carlospro7
no matter how many lines of php code you have in one file, the extension always has to be .php. If your file only has html and no php, it can also have the .php extension. The parser will just not read any code, it will send the html as it is to the browser.
kv
if you change the apache configuration, you can use any extension for php. If it is your local setup, you need to change httpd.conf. On frihost, you can add handler for your extensions.
yjwong
You can modify the Apache configuration to interpret other types of files as PHP. Just change the AddHandler directive to something else. For example:

Code:
AddHandler application/x-httpd-php .html .cpp

(This will let Apache parse .html and .cpp files as PHP files.)

If you don't want to modify your Apache configuration, there's another workaround. In your existing .php file, do something like:

Code:
<?php
$my_code = file_get_contents("my_html_file.html");
eval($my_code);
?>
salman_500
there is another way too... put the php code in the html file... and then include it in a php file.... Razz Wink
sb3700
You shouldn't keep PHP (or any server-side code) in a file that isn't getting parsed by the server.

A user might navigate to your HTML file and they will be able to see you PHP code. If there is anything important such as server infrastructure, or passwords, etc, the user will be able to see these.

the best way is to make a .htaccess file (you can make them on this host I think) ad add in it:
Code:
AddHandler application/x-httpd-php .html .htm

like ykwong suggested.

Just change .html and .htm, with as many different extensions as you want.

You can find more information on .htaccess files at:
http://www.javascriptkit.com/howto/htaccess.shtml

or just google it.
kawkazEE
put it in an html file then parse the html in your server (meaning dont just double-click it).. but the best choice is to use a php extension. Laughing Laughing Laughing
Diablosblizz
Can't you name .php extentions .php3 or .php4? I thought you could, never tried it because well .php is easy to remember, and well I don't like typing one whole number Razz.
Stubru Freak
Diablosblizz wrote:
Can't you name .php extentions .php3 or .php4? I thought you could, never tried it because well .php is easy to remember, and well I don't like typing one whole number Razz.


On most servers you can.
hostingguy
Yes on whichever line you put you must save it @ .php or the file won't be parsed by the php parser. php5 are used on servers the also can use PHP 5,
because some scripts do not work on PHP4 core Smile
Bejeweledhorses
you MUST put .php becuase php is an EXTENSION of HTML. Thus, when you put ".php" you are allowing essentially html with PHP in it.......

is it starting to make sense?

This you can't put php4 or php5 behind it becuase computers read it as .php and then sees if your localhost supports php4 , php5, or whatever


clear now?

I just thought that I could chip in my two cents.....^^

if i am mistaken, please yell at me for it.......^^
Related topics
Simple PHP Navigation
Simple PHP forum code needed!
PHP question
Simple PHP script not working
I need a VERY simple php script
another simple php request
Anyone care to help me with a simple PHP Form ?
simple php to mysql form doesn't work
A quick PHP Question! You know the answer! Answer ASAP .
MySQL and PHP Question
VERY simple php script needed
How to build simple PHP upload form
PHP question about passing variables (noob)
need help in a simple php register script based on flat file
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.