PHP Error Function name must be a string

0 votes

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
<?php
if ($_COOKIE('CaptchaResponseValue') == "false")
{
    header('location:index.php');
    return;
}
?>

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

Nov 4, 2020 in PHP by kartik
• 37,510 points
177 views

1 answer to this question.

0 votes

Hello @kartik,

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

$_COOKIE is an array, not a function.

Hope it helps!!

answered Nov 4, 2020 by Niroj
• 82,720 points

Related Questions In PHP

0 votes
1 answer

How to resolve “must be an instance of string, string given” prior to PHP 7?

Hello, Prior to PHP 7 type hinting can only be ...READ MORE

answered Apr 20, 2020 in PHP by I Navin
• 220 points
1,499 views
0 votes
0 answers
0 votes
1 answer

How can I use jquery $.ajax to call a PHP function?

Hello @kartik, Use $.ajax to call a server context (or ...READ MORE

answered Aug 27, 2020 in PHP by Niroj
• 82,720 points
1,966 views
0 votes
1 answer
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,720 points
7,118 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,720 points
814 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,720 points
632 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,720 points
7,540 views
0 votes
1 answer

How to call a php function from ajax?

Hello @kartik, You can't call a PHP function ...READ MORE

answered Jun 16, 2020 in PHP by Niroj
• 82,720 points
5,818 views
0 votes
1 answer

How PHP Replace last occurrence of a String in a String?

Hello @kartik, You can use this function: function str_lreplace($search, ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,720 points
262 views