[SOLVED] A few newbie questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
firkinfedup
Forum Newbie
Posts: 19
Joined: Sat Dec 04, 2004 7:25 am

A few newbie questions

Post by firkinfedup »

Hi there,

I've only just started to use PHP so I have a few questions that I desparately need to know before I can really bog down with development.

1) Are PHP scripts (source) totally invisible to the client? One of my scripts contains sensitive information and I'm frightened that there is a way to get the source of the page.

2) I want to make reusable functions / classes that I can "compile" and call in any PHP page to save myself from having to copy the script. Can this be done and how? Bearing in mind I am developing on a Windows XP Home system and uploading straight to the web server to test. One such function for example increments a hit counter and outputs HTML to display the counter. I would like to call this with 1 line, passing it the necessary parameters to increment the correct hit counter etc.

3) I've just made a function to parse the HTTP query, is there an easier way of doing this? Surely there is a function already written? I don't want to re-invent the wheel so to speak just because I miss something.

Thanks *LOADS* in advance for any help, I've been trying to post in the PHP newsgroups but my posts aren't getting through so I've come to a bit of a brick wall. Cheers again.

Nick.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Hello! Welcome to DevNetworks, hope you enjoy it!

1) As far as all the code is processed by PHP and only the result sent to the user, there is no way he can access it thru the web server. But if this user gains access to the system and your files are widely readable, there are a possibility that one can read the codes.

2) Read this reference:

Code: Select all

include[/php_man].

Code: Select all

<?php
include('class.dbconnection.inc');
$db = new DBConnection('marketing'); // connect to the 'marketing' database
?>

Code: Select all

<?php
include('class.counter.inc');
trackHit($_SERVERї'PHP_SELF']); // tracks hits for the current page
?>
3)Read these references:
firkinfedup
Forum Newbie
Posts: 19
Joined: Sat Dec 04, 2004 7:25 am

Post by firkinfedup »

Excellent! Just the information I was after, thanks loads! :-)
Post Reply