Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Not showing Php code when saved as html
Old 12-07-2005, 10:16 AM Not showing Php code when saved as html
Junior Talker

Posts: 1
Trades: 0
Hi Everyone,
I am a PhP newbie.
Can someome help me with this problem?

If I save the following code as a php file both html and the php resolves itself on my server but when I save the same code as a html file it only shows the html part but not the php:

<body>
Who is it?
<br/>
<?php
//print output
echo'fred'
?>
</body>
Bert Rum is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-07-2005, 06:04 PM
TrentonD's Avatar
Ultra Talker

Posts: 253
Location: Calgary, Alberta, Canada
Trades: 0
Do you mean that it is now showing "fred", or the whole php code?

(This:
<?php
//print output
echo'fred'
?>
)

You shouldn't be expecting either "fred" or the php code to show when saved as a .html file, because for the php code to actually work, it must be saved as a .php.

This is a real horrible, short explanation, but I hope you can understand what I mean.

Hopefully someone may add something to make this clearer, or maybe you already understand what I am saying?
__________________
Signature Coming Soon! :)
Please login or register to view this content. Registration is FREE
TrentonD is offline
Reply With Quote
View Public Profile Visit TrentonD's homepage!
 
Old 12-07-2005, 07:42 PM
HaRRo's Avatar
SEO Expert

Latest Blog Post:
The Large Hadron Collider
Posts: 522
Location: United Kingdom
Trades: 0
<body>
Who is it?
<br/>
<?php
//print output
echo'fred'
?>
</body>

This will echo the fred but when saving the file in your browser will change it to HTML not php.
It would be a security risk if you could.
__________________

Please login or register to view this content. Registration is FREE

What are you waiting for? Easy $$$ anyone can make a fortune!
CLICK CLICK CLICK CLICK CLICK CLICK CLICK CLICK CLICK
HaRRo is offline
Reply With Quote
View Public Profile Visit HaRRo's homepage!
 
Old 12-07-2005, 08:36 PM
Super Talker

Posts: 116
Trades: 0
PHP cannot be seen by the client side because its a server side script. This comes in handy when you have long complex scripts or when you have user authentification. It can still be hacked, but its more secure than having it in the source code. You should expect "Fred" to show up in your source rather than the <?php ?> tags etc.
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
Old 12-08-2005, 07:09 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
If your running apache you can add this

AddType application/x-httpd-php-source .phps

to your httpd.conf and then files you wish to display code on you remane file.phps. Then and only then can you display your source.

How do you do this in Windows or IIS.

Who cares.

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to Not showing Php code when saved as html
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42627 seconds with 12 queries