Reply to Re: Newbie PHP question: 'hiding' code on server from View Source

Your name:

Reply:


Posted by Carl Pearson on 01/16/07 17:31

murrayatuptowngallery@yahoo.com wrote:
> I have just started figuring out PHP as a server-side approach to
> something I did in Javascript.
>
> I never was able to figure out CGI on a remotely hosted web server the
> few times I tried (maybe wasnt' enabled?), but PHP is working fine...at
> least no problems at all, not my usual experience.
>
> What I would like to do is have the web page visitor access one page
> that 'calls' another so that the code isn't visible thru a web
> browser's 'View Source'.
>
> Can a .php or .htm file in the 'public', 'www', or 'html' directory
> access a .php file in for example the CGI-BIN area, or is there another
> way to do this?
>
> A visual example would probably help me more than a description.
>

Sorry, description first, then example. ;)

PHP is server side. It runs *before* anything is sent to the client.

What gets to the browser (the client) is the *result* of the script, not
the script itself.

Unless the server is set up wrong, the user should never be able to see
the actual php code.

This is unlike javascript, where the source code has to be downloaded to
the browser before it can run. That's why you can do a view source and
see javascript code (or at least the link to the code, if it's not
inline with the page).

Lastly, just to confuse things, there is server-side javascript as well,
but I've assumed here you were talking about client-side code that gets
run on the browser. Server-side javascript would be more for things
like syncronising info between a bunch of client calls, or calling
(perhaps proprietary) files or routines that lived on the server, not
the client's machine.

<html>
<head>
<title>My Page</title>
</head>
<body>
<!-- Some HTML Code -->
<?php include('subdir/file.php'); ?>
<?php include_once('subdir/file.php'); ?>
<?php require('subdir/file.php'); ?>
<?php require_once('subdir/file.php'); ?>
<!-- More HTML Code -->
</body>
</html>


Doing a view source would NOT show those php lines, just the result of
whatever they did.

Check out the manual or our good friend google on when to use which type
of include/require statement...

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация