[PHP] Re: preg_replace question

2003-02-23 Thread Phil Roberts
[EMAIL PROTECTED] (Electroteque) wrote in
news:[EMAIL PROTECTED]: 

> yet another regex question how could i hange the value within the
> quotes with preg_replace
> 
> php_value upload_max_filesize "5M"
> 
> 

$str = preg_replace("#php_value upload_max_filesize\s?['\"](.+?)[\"']#i", 
"php_value upload_max_filesize\"\\1\"", $str);

Should work.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: OOP and object references, not copies - how to do?

2003-02-23 Thread Phil Roberts
[EMAIL PROTECTED] (Erik FranzéN) wrote in
news:[EMAIL PROTECTED]: 

> Say the you are going to create a simple forum and you want to have a
> number of classes:
> 
> Class Sql - handles the DB interface
> Class User - handles users
> Class Messages - handles messages
> 
> When you are writing the code, you first creates a new sql object in
> order to read or write data from or to the database.
> 
> Secondly you create a user object in order to handle users, for an
> example, to authenticate the user which is going to write a new
> message in your forum.
> 
> The user object have a method which reads user information from the
> database.
>  Since you alread have created a sql object, this method should use
>  the sql 
> object in order to fecth data from the database.
> 
> I nice way to do this, would be to send the sql object as an reference
> to the user object constructor and store the object reference to the
> sql object in the user object.
> 
> This is not working very well in PHP yet because PHP cannot treat
> objects as references. When you send the sql object to the user object
> constructor method, it will be a copy, not a reference!
> 
> How do I get around this? There must be a way to handle this and
> create nice OOO PHP-code? I don't like using global variables as
> object handles. 
> 

You need to use the & chracter when passing & assigning.

$obj =& new Object;

function func(&$obj)
{

}

To return an object:

function &func()
{
return $obj;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Tutorials on OOP

2003-02-23 Thread Phil Roberts
[EMAIL PROTECTED] (Davy Obdam) wrote in news:[EMAIL PROTECTED]:

> Hi people,.
> 
> I have to build several classes for a project i am doing, but i am quite 
> new to OOP programming. I need to make a database abstraction layer 
> class and a user login class.. Does anyone know some good tutorials 
> about these things and OOP in general. Thanks in advance..
> 

http://www.phppatterns.com/ is a good place to learn about OO PHP design.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php