Function name must be a string

Function name must be a string

всем доброго времени суток.
Колдовал над php views.
вставил код в views Global PHP:

предпросмотр без проблем.
сохонить
белый экран:
Parse error: syntax error, unexpected ‘.’ in . /sites/all/modules/views_php/plugins/views/views_php_handler_field.inc(223) : runtime-created function on line 9

Fatal error: Function name must be a string in . /sites/all/modules/views_php/plugins/views/views_php_handler_field.inc on line 244

зашел через phpadmin, нашел таблицу view-display , отредактировал запись и оставил только
не помогло, тогда вообще удалил весь дисплей! не помогло, вернул бэкапом.
удалил /sites/all/modules/views_php/plugins/views/views_php_handler_field.inc заработало! но php не расчитывается (оно и понятно)

то есть, вот прям ни с того , ни с сего взяло и перестало работать (((((((((

I added the following lines to the top of my PHP code, but it throws an error:

Fatal error: Function name must be a string in /home/reg.php on line 2

I tried: $_COOKIE("CaptchaResponseValue") . The cookie is successfully set and is available. Why is it giving me an error when I am using $_COOKIE ?

8 Answers 8

It should be $_COOKIE[‘name’] , not $_COOKIE(‘name’)

$_COOKIE is an array, not a function.

Using parenthesis in a programming language or a scripting language usually means that it is a function.

However $_COOKIE in php is not a function, it is an Array. To access data in arrays you use square braces (‘[‘ and ‘]’) which symbolize which index to get the data from. So by doing $_COOKIE[‘test’] you are basically saying: "Give me the data from the index ‘test’.

Now, in your case, you have two possibilities: (1) either you want to see if it is false—by looking inside the cookie or (2) see if it is not even there.

For this, you use the isset function which basically checks if the variable is set or not.

Читайте также:  God of war какая часть лучше

Example

And if you want to check if the value is false and it is set you can do the following:

One thing that you can keep in mind is that if the first test fails, it wont even bother checking the next statement if it is AND ( && ).

And to explain why you actually get the error "Function must be a string", look at this page. It’s about basic creation of functions in PHP, what you must remember is that a function in PHP can only contain certain types of characters, where $ is not one of these. Since in PHP $ represents a variable.

A function could look like this: _myFunction _myFunction123 myFunction and in many other patterns as well, but mixing it with characters like $ and % will not work.

Comments

Copy link Quote reply

aftabnaveed commented Jun 4, 2018 •

in my laravel 5.6 application I am getting a strange error on every request.

What is possibaly going wrong here?

This comment has been minimized.

Copy link Quote reply

scil commented Jun 4, 2018

could you find more details?

Or set ‘tinker’ => true, in fly.conf.php and add eval(tinker()) ?

This comment has been minimized.

Copy link Quote reply

aftabnaveed commented Jun 4, 2018

I already have the xdebug enabled, otherwise PHP won’t print the stack trace 🙂

@scil Where should I add eval(tinker()) ?

This comment has been minimized.

Copy link Quote reply

scil commented Jun 4, 2018

eval(tinker()) can be placed everywhere almost.

open https://github.com/scil/LaravelFly and click "tinker use examples.( 🎃 click me!)",
there are some examples.

Читайте также:  Gsm gprs gps tracker manual

This comment has been minimized.

Copy link Quote reply

aftabnaveed commented Jun 4, 2018

OK thanks, I figured it out and tried, but it would take me some time to use it properly. The error seems to be associated with a middleware. I will try to use xdebug to see the problem.

This comment has been minimized.

Copy link Quote reply

aftabnaveed commented Jun 4, 2018

Ok I got a bit closer to the issue. I have a named middleware that I registered in App/Http/Kernel.php. The trouble is when it gets to the Line 152 of IlluminatePipelinePipeline it for some reason is not able to obtain its class thus causing the error.

My current application is perfectly working fine with default PHP-FPM setup.

Ссылка на основную публикацию
Adblock detector