0

I was setting up a PHP server when this error came up:

Strict Standards: Only variables should be passed by reference in C:\xamp\htdocs\Xce Source\Source\Extra\Xce.php on line 75 PHP Strict Standards: Only variables should be passed by reference in C:\xamp\htdocs\Xce Source\Source\Extra\Xce.php on line 75

This is the line 75:

$ready = socket_select($read, $w = null, $e = null, $t = 0);

What do I need to change? I always have this problem with exactly this same code

Parfait
  • 104,375
  • 17
  • 94
  • 125
Taro Yamada
  • 23
  • 1
  • 2
  • 1
    Please consider revising the code sample you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a [great resource](http://stackoverflow.com/help/mcve) to get you started on that. -1, don't take it the wrong way. A down vote is how we indicate a content problem around here; improve your formatting and code sample and I (or someone will) gladly revert it. Good luck with your code! – Skam Aug 05 '17 at 20:03
  • your grammar? no seriously remove the assignment `$w = null` and pass just the variable `$w` or `null` or in the case this is a copy and paste error and you don't want those last 3 remove them. – ArtisticPhoenix Aug 05 '17 at 20:15
  • actually `null` wont work in this case from the PHP documents site `Due a limitation in the current Zend Engine it is not possible to pass a constant modifier like NULL directly as a parameter to a function which expects this parameter to be passed by reference` – ArtisticPhoenix Aug 05 '17 at 20:19
  • 1
    Possible duplicate of [Strict Standards: Only variables should be passed by reference](https://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – vascowhite Aug 05 '17 at 20:37

2 Answers2

1

Instead of $ready = socket_select($read, $w = null, $e = null, $t = 0); use this:

$w = null;
$e = null;
$t = 0;

$ready = socket_select($read, $w, $e, $t);

When you do something like this $w = null as a function parameter, you are actually passing null, not a reference to the $w variable. socket_select requires references as parameters to work.

Anis Alibegić
  • 2,941
  • 3
  • 13
  • 28
1

As said in the documentation there, it should be:

$w = null; 
$e = null; 
$t = 0; 
$ready = socket_select($read, $w, $e, $t)
funilrys
  • 787
  • 9
  • 20
  • Thanks, sorry i am new in this and i didn't wanted to screw the code ;D – Taro Yamada Aug 05 '17 at 20:10
  • No problem @TaroYamada :) Keep something in mind: The documentation is the bible when coding :D Don't forget to accept the answer and vote if my answer helped. Have a nice day/night. – funilrys Aug 05 '17 at 20:16