Re: [PHP-DEV] Extension help

2001-03-20 Thread Barry Mitchelson

ok, I have managed to add a member variable, but am having problems when i try to 
retreive it using zend_find_hash

here's the code :

for the extension :

PHP_FUNCTION(create_object)
{

... other stuff

add_property_string(return_value,"foo","hello!",1);

... other stuff
}

PHP_FUNCTION(my_other_function)
{
zval **tmpString;
zval *obj;

obj = getThis();


zend_hash_find(obj-value.obj.properties,"foo",sizeof("foo"),(void**)tmpString);

convert_to_string_ex(tmpString);

zend_printf("foo = %s",tmpString);
}

that doesn't work :(

but in a php script it does :

?
$myObject = create_object();

echo $myObject-foo;

?

produces "hello!"

what am i doing wrong ?!

barry

On Mon, Mar 19, 2001 at 07:01:44PM -0500, Sterling Hughes wrote:
 On Mon, 19 Mar 2001, Barry Mitchelson wrote:
 
  hey,
  
  I'm writing an extension which defines a class.  In the constructor, I'd like to 
create a member variable which I can then access with the other member functions in 
my extension.
  
  In php it would be like :
  
  class foo
  {
  
  var $m_bar;
  
  function foo()
  {
  $this-m_bar = 123;
  }
  
  function a()
  {
  return $this-m_bar;
  }
  
  }
 
 
 look at adding it to the value.obj.properties of the class (its a
 HashTable).
 
 -Sterling
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Extension help

2001-03-20 Thread Barry Mitchelson

On Tue, Mar 20, 2001 at 03:24:00PM +0100, Marc Boeren wrote:
 
 
 zend_hash_find(obj-value.obj.properties,"foo",sizeof("foo"),(void**)tmpSt
 ring);
 
 You're almost correct, sizeof("foo") should be sizeof("foo")+1


hmm... still not working :(
 
 Cheerio, Marc.
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Extension help

2001-03-20 Thread Barry Mitchelson

On Tue, Mar 20, 2001 at 03:59:29PM +0100, Marc Boeren wrote:
 
  You're almost correct, sizeof("foo") should be sizeof("foo")+1
 
 hmm... still not working :(
 
 My fault for not reading on beyond the first typo:
 
 zend_printf("foo = %s",tmpString);
 
 should probably be
 
 zend_printf("foo = %s", (*tmpString)-value.str.val);
 
 but I may be wrong on the level of indirection.
 The zval cannot automagically be put in a %s and treated as a string, you
 should manually extract the pointer to the actual string.

even though i did convert_to_string_ex(tmpString) ?

 
 Hope this helps!
 
 Cheerio, Marc.
 (btw, you might have a look at the way the zval struct is set up in the
 source code)
 
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Extension help

2001-03-20 Thread Barry Mitchelson

On Tue, Mar 20, 2001 at 05:15:58PM +0100, Marc Boeren wrote:
 
 BTW, (*tmpString)-value.str.val == Z_STRVAL_PP(tmpString) but the
 latter looks much nicer :)
 
 Granted, but that's what happens if you just examine the code and don't read
 the documentation :-)

is there full documentation of the Zend API - i found the stuff on the zend website to 
be useful, but didn't cover everything.

 
 Cheerio, Marc.
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Extension help

2001-03-20 Thread Barry Mitchelson

On Tue, Mar 20, 2001 at 06:48:39PM +0200, Stanislav Malyshev wrote:
 BM is there full documentation of the Zend API - i found the stuff
 BM on the zend website to be useful, but didn't cover everything.
 
 Well, that's the most full one that exists. Eventually, it should be
 extended to cover the most, but before it happnes, you have the code and
 the PHP-DEV...
 

yeah, think once i get my extension finally working I may write a tutorial on creating 
something more advanced than running ext_skel and adding a function - eg, defining a 
class, using objects etc..

 -- 
 Stanislav Malyshev, Zend Products Engineer
 [EMAIL PROTECTED]  http://www.zend.com/ +972-3-6139665 ext.115
 
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Extension help

2001-03-19 Thread Barry Mitchelson

hey,

I'm writing an extension which defines a class.  In the constructor, I'd like to 
create a member variable which I can then access with the other member functions in my 
extension.

In php it would be like :

class foo
{

var $m_bar;

function foo()
{
$this-m_bar = 123;
}

function a()
{
return $this-m_bar;
}

}

but I can't figure out how to do it within the extension.

thanks,


barry

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] advice

2001-03-18 Thread Barry Mitchelson

hi all,

can anyone give me the url to a tutorial on creating a php extension - specifically 
creating a new class which will be available to all scripts.  I've read through the 
Zend api docs, and have created a new function, but haven't found any good guides to 
adding a new class.  If there aren't any guides, then some sample code would be much 
appreciated :)


regards,

Barry

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Err : Invalid library

2001-03-13 Thread Barry Mitchelson

hi,

i've been playing around with the php-gtk extension (don't worry this is not OT), but 
am having problems after installing the latest cvs version of php4.

when I try and run a script (and even when i do 'php -v') i get the following error :

PHP Warning:  Invalid library (maybe not a PHP library) 'php_gtk.so'  in Unknown on 
line 0

now, I know that this library works because I had it running with my previous cvs 
version of php.  I've tried reinstalling php-gtk, and also php4 from both cvs and 
snaps.php.net but still the same problem.

has anyone got any ideas what could be causing this problem ?

thanks,

barry

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Err : Invalid library

2001-03-13 Thread Barry Mitchelson

many thanks :)

barry

On Tue, Mar 13, 2001 at 07:46:32PM +0200, Alexander Bokovoy wrote:
 On Tue, Mar 13, 2001 at 05:24:58PM +, Barry Mitchelson wrote:
  hi,
  
  i've been playing around with the php-gtk extension (don't worry this is not OT), 
but am having problems after installing the latest cvs version of php4.
  
  when I try and run a script (and even when i do 'php -v') i get the following 
error :
  
  PHP Warning:  Invalid library (maybe not a PHP library) 'php_gtk.so'  in Unknown 
on line 0
  
  now, I know that this library works because I had it running with my previous cvs 
version of php.  I've tried reinstalling php-gtk, and also php4 from both cvs and 
snaps.php.net but still the same problem.
  
  has anyone got any ideas what could be causing this problem ?
 Yes and I have partial solution. Not pretty though but it works for me at least.
 So, problem caused by several things:
 
 1. Build environment for self contained extensions (SCE) is generally broken
 in PHP4. It wasn't work in past, it does not work now in one
 particular case: when you have several PHP_ARG_WITH or PHP_ARG_ENABLE   
 in config.m4. In case of SCE, all of these macroses get positive
 answer regardless of user input or library checks because of this code
 in PHP_ARG_ANALYZE (acinclude.m4):
 
 if test "$php_always_shared" = "yes"; then
   ext_output="yes, shared"
   ext_shared=yes
   test "[$]$1" = "no"  $1=yes
 fi
 
 So, even if user states PHP_SOMETHING = no, this code will rewrite it to
 PHP_SOMETHING = yes
 
 This particulary touches 'readline', 'mysql', 'dba', 'interbase',
 'mcrypt', 'mhash' and other extensions.
 
 2. PHP-GTK suffers from other bug. It is also a problem with build
 environment: when you do
 
 #include "php_config.h"
 
 in SCE module, then main PHP4 php_config.h which is installed on the
 system is included, not locally created php_config.h which contains
 proper definitions of HAVE_PHP_GTK and COMPILE_DL_PHP_GTK symbols.
 
 In the CVS version of PHP4 header file which is generated as SCE config
 file is renamed to config.h from php_config.h few days ago. But modules
 themselves were not updated, so there are no modules in PHP4 than really
 include config.h from the current directory, so HAVE_MODULENAME will be
 undefined for all of them (if they are compiled as SCE) and all code
 will be skipped due
 
 #if HAVE_MODULENAME
  actual code
 #endif
 
 in most of them.
 
 This particulary touches PHP-GTK, mysql, dba, and most of other modules.
 
 Solution for PHP-GTK is to pass -DHAVE_PHP_GTK=1 -DCOMPILE_DL_PHP_GTK=1 to configure
 through CFLAGS. Or fix SCE build environment (macros in acinclude.m4, pear/pear.m4
 and #include "php_config.h" in all modules).
 
 -- 
 Sincerely yours, Alexander Bokovoy 
   The Midgard Project   | www.midgard-project.org |Aurora RD team 
 Minsk Linux Users Group |www.minsk-lug.net|  www.aurora-linux.com  
 ALT Linux Team  |www.alt-linux.org| Architecte Open Source
 -- Conscience is what hurts when everything else feels so good.
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
http://www.theshining.org

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]