Re: Compare Values

From: Date: Sun, 27 Jun 2004 00:40:09 +0000
Subject: Re: Compare Values
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-896@lists.php.net to get a copy of this message
Hi Frank, What you really want to use is zend_parse_parameters, and it will correctly handle the conversions for you. PHP_FUNCTION(checkval) { char *val; int vallen; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &val, &vallen)) { return; } if (0 == strncmp(val, "1234567890", 10)) { ... first 10 chars are equal .... } } ----- Original Message ----- From: "Frank Liebelt" <frank.liebelt@edico-gmbh.de> To: "PECL DEV Mailinglist" <pecl-dev@lists.php.net> Sent: Saturday, June 26, 2004 6:47 PM Subject: AW: [PECL-DEV] Compare Values Hi > I dont think anyone here is going to laugh, expecially with someone > trying to learn something. Thanks > You might want to read the whole chapter 9 of the Zend API, it > pretty much explains on how to accept paramaters from the php call. > > http://www.zend.com/apidoc/zend.arguments.php > > Your PHP_FUNCTON() logic will be something like: > > 1. parse out variables from php script. > 2. evaluate what they passed. > 3. return a value to the php script > > > The fix value looks like so: > > char *FIXED(void) { return "4789872983"; ); > > > > I simply want to convert both values into a string to > compare, but ever i > > use > > convert_to_string_ex() the apache server crashed. I read the doc but that what i want would'nt work. Here is what i have now: (Don't care about the function name. I will i rename if it worked) PHP_FUNCTION(checkval) { zval **parameter; char *key = NULL; key = "6575736883"; /* argument count is correct, now retrieve arguments */ if((ZEND_NUM_ARGS() != 1) || (zend_get_parameters_ex(1, &parameter) != SUCCESS)) { WRONG_PARAM_COUNT; } convert_to_string_ex(parameter); RETURN_STRING(*parameter,0); } This is for testing only. I send the parameter from the php script like this: echo checkval("65757368837485728368818481837172906871837778837274"); Normally im awaiting a printout of : 65757368837485728368818481837172906871837778837274 But in my Browser i allways see such crypt character : à-22 which is changing after every reload. This isnt my real problem. But this her is: How can i compare the first 10 characters from the given value with the defined key? I dont want other to do my work but a sample function that does my needs would be fine. So i could learn from that. Thanks in advance Frank ____________ Virus checked by Antivirus-Profi-Paket Version: AVK 14.0.1217 from 19.06.2004 Virus news: www.antiviruslab.com -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pecl.dev (#896) next »