You are here: Re: [PHP] Extensions: parameters as references « PHP « IT news, forums, messages
Re: [PHP] Extensions: parameters as references

Posted by Yasir Malik on 06/18/05 01:49

Is there any list (or forum) that can help me with this?

Thanks,
Yasir

On Fri, 17 Jun 2005, Yasir Malik wrote:

> Date: Fri, 17 Jun 2005 11:51:24 -0400 (EDT)
> From: Yasir Malik <ymalik@cs.stevens.edu>
> To: php-general@lists.php.net
> Subject: [PHP] Extensions: parameters as references
>
> I am creating a PHP extension. In my function, I want the parameter to be a
> reference. The extension function works fine only if the variable passed is
> initialized. For example, here is the extension function:
> ZEND_FUNCTION(first_module)
> {
> zval *parameter;
>
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
> "z", &parameter) == FAILURE)
> return;
>
> ZVAL_LONG(parameter, 78);
> }
>
> When I call this as
> <?php
> dl("test.so");
> $a = 4;
> first_module($a);
> print "$a\n";
> ?>
>
> it works fine, but when I call it as:
> <?php
> dl("test.so");
> first_module($a);
> print "$a\n";
> ?>
>
> nothing is outputted. I looked at the source code for various extensions,
> and I noticed that they called the deconstructor zval_dtor(). I tried this,
> but it still did not work:
> ZEND_FUNCTION(first_module)
> {
> zval *parameter;
>
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
> "z", &parameter) == FAILURE)
> return;
>
> zval_dtor(parameter);
> ZVAL_LONG(parameter, 78);
> }
>
> Thanks,
> Yasir
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация