Class's and Variables

From: Date: Tue, 13 May 2003 23:24:14 +0000
Subject: Class's and Variables
Groups: php.general 
Request: Send a blank email to php-general+get-147506@lists.php.net to get a copy of this message
Hi, I've got a PHP class off the web and there's a change or two I'd like to make to one of the functions. So I have a question on adding private variables. Let's say I want to connect to my database, Postgresql, is it OK to just add the required variable's to the method itself or should the variable's be set at the start of the class. I hope my code example below helps explain my question: class UploadImage { var $image; function UploadImage($image) { $this->image=stripslashes($image); } function CopyFile() { $conn = pg_connect("dbname=oasis_net"); $sql = "INSERT INTO images ( i_base64 ) VALUES 'myImage');"; $res = pg_exec($conn,$sql); $conn = pg_close($conn); } } Is it OK to set the $res variable in CopyFile() like above or should it be set where the $image variable is set. Thanks heaps. Regards Rudi.

« previous php.general (#147506) next »