Functions

Zend Engine 2 Functions

zend_atoi()

Converts a string containing a suffix into an integer

zend_atoi(const char* str, int str_ren)


Returns:

int

Parameters:

type parameter description
const char* str string to convert
int str_len number of characters in the string, if 0 is given this will be calculated

This function converts a string containing numbers and ending in k, K, m, M, g or G into an appropriate integer. For example, "2K" will become 2048; "5G" will become 5368709100

Example:

bytes = zend_atoi("100G",0);

zend_register_internal_class()

Registers a class

zend_register_internal_class_ex(zend_class_entry *orig_class_entry TSRMLS_DC)


Returns:

zend_class_entry*

Parameters:

type parameter description
zend_class_entry* orig_class_entry class entry of the class you are registering
void*** TSRMLS_DC used to pass a reference to the current thread; you should generally pass the TSRMLS_C macro for this paremeter (or skip the comma in front of it and use TSRMLS_CC)

Note: A class that contains any abstract methods will automatically become an abstract class

Example:

myChild = zend_register_internal_class(&myChild_ce TSRMLS_CC);

zend_register_internal_class_ex()

Registers a class which inherts from a parent class

zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC)


Returns:

zend_class_entry*

Parameters:

type parameter description
zend_class_entry* class_entry class entry of the class you are registering
zend_class_entry* parent_ce class entry of the parent from which this inherits
char* parent_name name of the parent class
void*** TSRMLS_DC used to pass a reference to the current thread; you should generally pass the TSRMLS_C macro for this paremeter (or skip the comma in front of it and use TSRMLS_CC)

If parent_ce is not NULL then it inherits from parent_ce

If parent_ce is NULL and parent_name isn't then it looks for the parent and inherits from it

If both parent_ce and parent_name are NULL it does a regular class registration

If parent_name is specified but not found NULL is returned

Example:

myChild = zend_register_internal_class_ex(&myChild_ce,&myParent_ce,NULL TSRMLS_CC);

zend_string_to_double()

Converts a char* into a double

zend_string_to_double(const char *number, zend_uint length)


Returns:

double

Parameters:

type parameter description
const char* number string you wish to convert to a number
zend_uint length number of characters from the string to convert, starting from the beginning. If 0 this function will return 0.0.

Convert a string into a double, if the string contains an E or e, the numbers after it will be used as an exponent; for example "2E2" will become 200.0

Example:

d = zend_string_to_double("34.54", 5);