[PHP] distinguish between null variable and unset variable

2009-01-21 Thread Jack Bates
How can I tell the difference between a variable whose value is null and a variable which is not set? // cannot use === null: ket% php -r '$null = null; var_dump(null === $null);' bool(true) ket% php -r 'var_dump(null === $unset);' bool(true) ket% // - cannot use isset() either: k

[PHP] get file from object

2009-01-06 Thread Jack Bates
How do I get the file where a class is defined, from an instance of that class? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: runtime access to static variable

2008-12-17 Thread Jack Bates
> this does beg the question why don't you know the classname at runtime.. > seems to be a slight design flaw and may make sense for you to post the > full problem (you must have chosen to implement this for a reason..) The full problem is: I started off with a "DeployTask" for deploying a new i

[PHP] runtime access to static variable

2008-12-16 Thread Jack Bates
How do I access a static variable when I do not know the name of the class until runtime? I have the following example PHP: ket% cat test.php http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] new $foo->className(); Class name must be a valid object or a string

2008-05-03 Thread Jack Bates
I am trying to load PHP objects stored in a database, where the class name is stored in a column: $object = new $resultSet->getString(1); This fails for the same reason that the following fails: className(); Fatal error: Class name must be a valid object or a string in test.php on line 12 I gu

[PHP] redirect stdout to stderr

2008-02-22 Thread Jack Bates
How can I implement in PHP, a script which redirects stdout to stderr, such that echo, etc. print to stderr instead of stdout? I can redirect stdout to stderr when invoking PHP like so: php script-name >&2 However I want to perform this redirection within the script itself. The solution I curre

[PHP] [pcre] backreferences to all matches of a repeated subexpression

2007-08-01 Thread Jack Bates
I'm trying to pull all the components out of strings structured like: word followed by any number of ( dot word or square bracketed string ) This is an example: foo.bar[ab.cd].baz >From the above example, I want: array('foo', 'bar', 'ab.cd', 'baz'); A regular expression to match these strings, i