PHP, Как знать, является ли переменная ссылкой?

Фильтры плагина Photoshop. Партии и большое интересное графическое управление, которое можно сделать с теми и Вам будет нужен чистый C для выполнения в нем.

, Например, это - шлюз к фрактальному поколению, преобразованиям Фурье, нечеткие алгоритмы и т.д. и т.д. Действительно что-либо, что может управлять данными изображения/цвета и дать интересные результаты

6
задан Hubert Kario 6 February 2012 в 00:51
поделиться

2 ответа

No, the issue is that the first parameter of the function is pass-by-reference (meaning the function can modify the argument in the caller's scope). Therefore, you must pass a variable or something which is assignable as the first argument. When you create the array like array($a), it just copies the value of the variable $a (which is 0) into a slot in the array. It does not refer back to the variable $a in any way. And then when you call the function, it is as if you're doing this, which does not work:

test(0)

If you really wanted to, you could put $a into the array by reference, but it's kinda tricky:

<?php
$a = 0;
$args = array(&$a);
function test(&$a) {
    $a++;
}
call_user_func_array('test', $args);
?>

As to how you would tell, that the array element is a reference... that is hard. You could do var_dump() on the array, and search for the "&" symbol:

> var_dump($args);
array(1) {
  [0]=>
  &int(1)
}
3
ответ дан 17 December 2019 в 07:06
поделиться

Check out the comments on this PHP documentation page:

http://php.net/manual/en/language.references.spot.php

1
ответ дан 17 December 2019 в 07:06
поделиться
Другие вопросы по тегам:

Похожие вопросы: