Menu
  • HOME
  • TAGS

PHP 7 return dynamic alloc zval right way

php,zend-framework,php-extension,php-7

ok answered it to myself :D problem was the **pointer. Final code - did it: zval * params = NULL; zval * t; int i = 0; int arg_num = lua_gettop(L); params = safe_emalloc(sizeof(zval), arg_num, 0); //if(arg_num >= 100) return 0; for (i=0; i<arg_num; i++) { //params[i]=ecalloc(1, sizeof(zval)); //params[i] =...

Spaceship operator <=> in PHP 7

php-7,spaceship-operator

The comparison operator documentation on php.net defines how comparing different types is handled. Usually some implicit conversion is involved.

How to use Combined comparison Operator (<=>) and null coalescing operator (??) in php 7

php,php-7

The combined comparison operator return -1, 0, or 1, depending on which is greater than the other: if ($x <=> $y == -1) { echo '$x < $y'; } elseif ($x <=> $y == 1) { echo '$x > $y'; } else { echo '$x == $y'; } The null...

Type hinting and multiple constructors

php,php-7

Correct, that's one of the limitations of the language. (and the strlen() > 0 anyway can't be checked via a type. That auto-casts to string… so your method allows everything but "", null and false?) Generally, there is RFCs in draft to expand the typehinting of PHP in 7.1: https://wiki.php.net/rfc/union_types...

Trying to understand array_diff_uassoc optimization

php,arrays,sorting,php-7

Sorting algorithm didn't change in PHP 7. Elements are just passed in another order to the sorting algorithm for some performance improvements. Well, benefit could be an eventual faster execution. You really hit worst case when both arrays have completely other keys. Worst case complexity is twice sorting the arrays...

Null coalescing operator also usable with falsy values, but not nulls?

null-coalescing-operator,php-7

I created this which should answer you questions. Anyhow The operator can be chained and it will return the first element in the chain that is set and not null. According to the documentation it will return the result of its first operand if it exists and is not NULL,...

Specifying return type from function

php,function,return,php-7

Return types have just been accepted into PHP 7. The return type is part of the function declaration, not its definition. Unless you're making an abstract function or interface, that won't make much difference. Combining your code with what's in that RFC, you would do: class barCl { function _construct()...

What is '<=>' 'Spaceship' Operator in PHP7?

php,operators,php-7,spaceship-operator

This <=> operator will offer combined comparison in that it will : Return 0 if values on either side are equal Return 1 if value on the left is greater Return -1 if the value on the right is greater The rules used by the combined comparison operator are same...

PHP 7 Fatal error: static::class cannot be used for compile-time class name resolution [closed]

php,php-7

Fixed this bug via http://git.php.net/?p=php-src.git;a=commitdiff;h=1d3f77d13d2b457bdf1bc52045da4679741e65cb The mistake was simple... I had in compile time constant resolution optimization set the mode to force succeed or die (a simple boolean to a function call). That mode is needed for static expressions (like const FOO = static::class; must fail). Set that to zero...