Re: [PHP] PHPEclipse?

2004-07-13 Thread David Goodlad
Hi Dan

I am the one building all the phpeclipse cvs releases.  The latest zip
file was corrupted (July 11, 2004), but the previous one works.  Or,
wait until tomorrow early morning when I will post a working CVS build
for this week.

I am using it and building it on Eclipse 3.0 in linux/gtk, but by all
accounts it works just fine under win32 as well.  The only thing that
I personally can't get working is the debugger, but haven't spent much
time on it as var_dump statements serve me just fine for now.

Dave

On Mon, 12 Jul 2004 14:39:36 -0400, Dan Joseph [EMAIL PROTECTED] wrote:
 Hi,
 
 I was wondering, is anyone running Eclipse 3.0 w/PHPEclipse 1.1.0?
 I'm having trouble getting it working.  I downloaded the July .ZIP file and
 unzipped it into the plugins directory.  Its not recognizing it.  Anyone
 have this working?
 
 -Dan Joseph

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



Re: [PHP] Re: Saving variables in a session in a destructor

2004-06-30 Thread David Goodlad
Ahh, guess I didn't look hard enough!  Thanks!

Dave

On Wed, 30 Jun 2004 10:10:29 +0200, Red Wingate [EMAIL PROTECTED] wrote:
 
 Maybe you check out the internals archives as an discussion about this topic
 was held 1-2 days ago.
 
 
  Hi all
 
  Using PHP5, I am trying to save some properties of an object when it
  is destroyed in its destructor, __destruct().  However, I have found
  that the session variable is NOT stored unless I explicitly destroy
  the object using unset().  If I leave php to finish executing the
  script and automatically destroy the object, the destructor IS called,
  however, the session variables are NOT saved.  A quick code example
  for clarity:
 
  -
  class StateMachine {
public $stateVariable;
function __destruct() {
  $_SESSION['state'] = $this-stateVariable;
}
  }
 
  $sm = new StateMachine();
  if (isset($_SESSION['state'])) {
$sm-stateVariable = $_SESSION['state'];
  } else {
$sm-stateVariable = 'foobar';
  }
  
 
  (please ignore the obvious bad coding standard of making that var
  public and accessing it, this is for simplicity of the example).
 
  Unless I do an unset($sm); at the end of a script like this, the
  $_SESSION array will never contain the state=foobar key/value.
 
  Can anyone offer some insight into this?
 
  Thanks!
  Dave
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] Saving variables in a session in a destructor

2004-06-29 Thread David Goodlad
Hi all

Using PHP5, I am trying to save some properties of an object when it
is destroyed in its destructor, __destruct().  However, I have found
that the session variable is NOT stored unless I explicitly destroy
the object using unset().  If I leave php to finish executing the
script and automatically destroy the object, the destructor IS called,
however, the session variables are NOT saved.  A quick code example
for clarity:

-
class StateMachine {
  public $stateVariable;
  function __destruct() {
$_SESSION['state'] = $this-stateVariable;
  }
}

$sm = new StateMachine();
if (isset($_SESSION['state'])) {
  $sm-stateVariable = $_SESSION['state'];
} else {
  $sm-stateVariable = 'foobar';
}


(please ignore the obvious bad coding standard of making that var
public and accessing it, this is for simplicity of the example).

Unless I do an unset($sm); at the end of a script like this, the
$_SESSION array will never contain the state=foobar key/value.

Can anyone offer some insight into this?

Thanks!
Dave

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



Re: [PHP] Construction

2004-06-27 Thread David Goodlad
As far as I know, this is fairly common in most programming languages
(but I just woke up so don't take my word on it!).  It allows you a
lot greater control over the construction of your class, since you can
force the child class to override what the parent class's default
member variable values are by calling the parent constructor first, or
you can have it be overridden by the parent by calling the parent
constructor at the end of the child's constructor.

Dave

On Sat, 26 Jun 2004 20:51:58 -0700, Jason Davidson
[EMAIL PROTECTED] wrote:
 
 If you instantiate a child class, the parent class constructor is not
 called, is there a reason for this?  anyone know of plans to change
 this at all, 
 the obvious workaround is to call the parents constructor inside the
 childs constructor, but this seems kinda strange.
 
 Jason
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] a stupid question

2004-06-24 Thread David Goodlad
Perhaps using:

$ret = aFunction();
var_dump($ret);

Then you'll see if aFunction() is returning anything.

Dave

On Thu, 24 Jun 2004 16:48:18 -0500, Matt Matijevich
[EMAIL PROTECTED] wrote:
 
 [snip]
 echo Some text.aFunction().some more text;
 [/snip]
 
 Have you checked to see if aFunction() is returning anything?
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] static __get function

2004-04-24 Thread David Goodlad
Hi Marek

Thanks for the response

Two things you should notice is my declaration of the constructor as 
private and the $ConfigSettings variable as static. This class is 
designed in such a way that it can never be instantiated, preventing 
loading the configuration file twice and possibly having inconsistent 
copies of the config file in memory.

I've tried the __get and __set functions as just regular non-static 
ones, but same problem.

I am using self:: instead of $this- because of the reasons mentioned 
above about not wanting to instantiate the object, only have its static 
members loaded. In this way I refer to the class, not a specific 
instance of the class; a real instance should never really exist.

Dave

Marek Kilimajer wrote:

I'm not sure if it will help but do't define the magic functions as 
public static, use just:

function __get(...)

The function is not public anyway, as it should no be called directly.

And to my knowledge self:: references a class, not an object. You 
should use $this- instead.

David Goodlad static objectwrote:

Hi all...

I'm trying to build a simple configureation class (using the 
singleton pattern). Using PHP5, I want to use the __get and __set 
methods to access configuration settings for my site. However, they 
don't work :P Here's my class definition:

class Configuration {
static private $ConfigSettings;
private function __construct() {
}
public static function __get($Setting) {
if (!is_array(self::$ConfigSettings)) {
require_once(dirname(__FILE__) . '/../../configs/Framework.conf.php');
}
if (isset(self::$ConfigSettings[$Setting])) {
return self::$ConfigSettings[$Setting];
}
return NULL;
}
public static function __set($Setting, $Value) {
self::$ConfigSettings[$Setting] = $Value;
}
}
However, instead of doing something like:

Configuration::DbType = 'mysql';

I have to use:

Configuration::__set('DbType', 'mysql');

It works, yes, but not quite like I want it to - it just seems 'ugly' 
to me.

This is using PHP5 RC1 on Apache 2.0.49 (linux).

Any suggestions?

Dave


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


[PHP] static __get function

2004-04-23 Thread David Goodlad
Hi all...

I'm trying to build a simple configureation class (using the singleton 
pattern).  Using PHP5, I want to use the __get and __set methods to 
access configuration settings for my site.  However, they don't work :P 
 Here's my class definition:

class Configuration {
static private $ConfigSettings;
private function __construct() {

}
public static function __get($Setting) {
if (!is_array(self::$ConfigSettings)) {
require_once(dirname(__FILE__) . 
'/../../configs/Framework.conf.php');
}
if (isset(self::$ConfigSettings[$Setting])) {
return self::$ConfigSettings[$Setting];
}
return NULL;
}
public static function __set($Setting, $Value) {
self::$ConfigSettings[$Setting] = $Value;
}
}
However, instead of doing something like:

Configuration::DbType = 'mysql';

I have to use:

Configuration::__set('DbType', 'mysql');

It works, yes, but not quite like I want it to - it just seems 'ugly' to me.

This is using PHP5 RC1 on Apache 2.0.49 (linux).

Any suggestions?

Dave

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