confused - can not find PHP API function for 'die'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R

    confused - can not find PHP API function for 'die'

    Hello everybody.

    I'm looking for PHP API function for 'die'

    I'm messing with my own function - it's my own 'var_dump' - 'myDump'

    It works fine, but I want to end script after dumping variables.

    I found that Zend's lexer return T_EXIT token and creates zend_do_exit
    code - but I guest it's not what I need.

    So the question is:
    How can I end script from PHP API? I want to achieve exactly the same
    effect as:

    ---
    myDump($object) ;
    die();
    ---

    but I want it all in one function as:
    ---
    myDump($object) ;
    ---

    thanx in advance
    cheers R

  • Carl

    #2
    Re: confused - can not find PHP API function for 'die'

    R wrote:[color=blue]
    > Hello everybody.
    >
    > I'm looking for PHP API function for 'die'
    >
    > I'm messing with my own function - it's my own 'var_dump' - 'myDump'
    >
    > It works fine, but I want to end script after dumping variables.
    >
    > I found that Zend's lexer return T_EXIT token and creates zend_do_exit
    > code - but I guest it's not what I need.
    >
    > So the question is:
    > How can I end script from PHP API? I want to achieve exactly the same
    > effect as:
    >
    > ---
    > myDump($object) ;
    > die();
    > ---
    >
    > but I want it all in one function as:
    > ---
    > myDump($object) ;
    > ---
    >
    > thanx in advance
    > cheers R
    >[/color]

    R,

    Why wouldn't you just call exit() from within your function?

    function myDump($object) {
    //do something with object...
    exit();
    }

    Carl.

    Comment

    • R

      #3
      Re: confused - can not find PHP API function for 'die'


      Carl wrote:[color=blue]
      > Why wouldn't you just call exit() from within your function?
      >
      > function myDump($object) {
      > //do something with object...
      > exit();
      > }[/color]

      because I want to create PHP API function - forgive me but I know how
      to exit my script in plain PHP....

      PHP API goes sth like this:

      PHP_FUNCTION(my Dump)
      {
      zval *var;
      zend_bool i = 0;

      if (zend_parse_par ameters(ZEND_NU M_ARGS() TSRMLS_CC, "z|b", &var,
      &i) == FAILURE) {
      RETURN_FALSE;
      }

      /* do my thing in C */

      }

      and I want to call die function from myDump - but I can not make it.

      thanks in advance for any help
      cheers R

      Comment

      • Carl

        #4
        Re: confused - can not find PHP API function for 'die'

        R wrote:[color=blue]
        > Carl wrote:
        >[color=green]
        >>Why wouldn't you just call exit() from within your function?
        >>
        >>function myDump($object) {
        >> //do something with object...
        >> exit();
        >>}[/color]
        >
        >
        > because I want to create PHP API function - forgive me but I know how
        > to exit my script in plain PHP....
        >
        > PHP API goes sth like this:
        >
        > PHP_FUNCTION(my Dump)
        > {
        > zval *var;
        > zend_bool i = 0;
        >
        > if (zend_parse_par ameters(ZEND_NU M_ARGS() TSRMLS_CC, "z|b", &var,
        > &i) == FAILURE) {
        > RETURN_FALSE;
        > }
        >
        > /* do my thing in C */
        >
        > }
        >
        > and I want to call die function from myDump - but I can not make it.
        >
        > thanks in advance for any help
        > cheers R
        >[/color]


        R,

        O.K., The fact that you were trying to write an extension using the API
        was not clear to me from your initial post.

        Also, it may be helpful to know that die()/exit() are actually
        implemented as a language construct in php, not as a function.

        You may want to try and repost this on the php-dev ML as you will
        probably get more appropriate answers there.

        Carl.

        Comment

        Working...