Re: [PHP] Classes and access to outside variables
- From: ryu.pan@xxxxxxxxx ("潘志彬")
- Date: Sun, 30 Sep 2007 13:08:11 +0800
$dbh = 'test';
class search_helper extends AjaxACApplication
{
/**
* Database connection details
*/
// announce global variable before use it
global $dbh;
$db_hostname = $dbh;
...
Regards,
Ryu
2007/9/29, Merlin <ngroups@xxxxxxxxxxx>:
Hi there,
I am new to PHP classes and I do want to access a variable outside the
class, but somehow that does not work. global also does not have any
effect.
In the following example I would like to be able to access $dbh from
inside the class like I did in that example. This does not work. Can
somebody please give me a hint on the right syntax?
$dbh = 'test';
class search_helper extends AjaxACApplication
{
/**
* Database connection details
*/
var $db_hostname = $dbh;
Thank you for any help,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- Follow-Ups:
- Re: [PHP] Classes and access to outside variables
- From: "Martin Alterisio"
- Re: [PHP] Classes and access to outside variables
- From: "Nathan Nobbe"
- Re: [PHP] Classes and access to outside variables
- References:
- Classes and access to outside variables
- From: Merlin
- Classes and access to outside variables
- Prev by Date: Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- Next by Date: Re: [PHP] Beginner Tutorials for using CLASSES in PHP4
- Previous by thread: Re: [PHP] Classes and access to outside variables
- Next by thread: Re: [PHP] Classes and access to outside variables
- Index(es):