Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Php Extension with C++

Links for php scripts

Moderators: macek, egami, gesf

Php Extension with C++

Postby Antrikssh » Thu May 24, 2012 6:08 am

Hello,

my.php file

<?php
$parameter = 0;
get_data(&$parameter);
print $parameter;
?>

Employe.c

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_Employe.h"


/* True global resources - no need for thread safety here */
static int le_Employe;

/* {{{ Employe_functions[]
*
* Every user visible function must have an entry in Employe_functions[].
*/
const zend_function_entry Employe_functions[] = {
PHP_FE(confirm_Employe_compiled, NULL) /* For testing, remove later. */
PHP_FE(get_data, NULL)
PHP_FE_END /* Must be the last line in Employe_functions[] */
};
/* }}} */

/* {{{ Employe_module_entry
*/
zend_module_entry Employe_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"Employe",
Employe_functions,
PHP_MINIT(Employe),
PHP_MSHUTDOWN(Employe),
PHP_RINIT(Employe), /* Replace with NULL if there's nothing to do at request start */
PHP_RSHUTDOWN(Employe), /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(Employe),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */

#ifdef COMPILE_DL_EMPLOYE
ZEND_GET_MODULE(Employe)
#endif

PHP_MINIT_FUNCTION(Employe)
{
/* If you have INI entries, uncomment these lines
REGISTER_INI_ENTRIES();
*/
return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(Employe)
{
/* uncomment this line if you have INI entries
UNREGISTER_INI_ENTRIES();
*/
return SUCCESS;
}

PHP_RINIT_FUNCTION(Employe)
{
return SUCCESS;
}

PHP_RSHUTDOWN_FUNCTION(Employe)
{
return SUCCESS;
}

PHP_MINFO_FUNCTION(Employe)
{
php_info_print_table_start();
php_info_print_table_header(2, "Employe support", "enabled");
php_info_print_table_end();

/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
}
/* }}} */


/* {{{ proto int get_data(int )
*iVal) */
PHP_FUNCTION(get_data)
{
int argc = ZEND_NUM_ARGS();
long para;

if (zend_parse_parameters(argc TSRMLS_CC, "l", &para) == FAILURE)
{return;}
para = 10;
php_printf("Value = %d",para);

//php_error(E_WARNING, "show_result_emp: not yet implemented");
}
/* }}} */

If I execute my.php then the O/P of print $parameter is 0 while O/P of php_printf("Value = %d",para); is 10 on the browser.

Please help me to out of this....

Thanks and Regards,

Antrikssh..... :)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Return to PHP Scripts

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.