1

I am using CakePHP 2.X latest. Facing unique error.

This is error i am getting:

Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object [CORE/Cake/Utility/ObjectCollection.php, line 132]

Warning (2): call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object [CORE/Cake/Utility/ObjectCollection.php, line 132]

Fatal error: Call to a member function link() on a non-object in /data/html/savaganza/app/View/Elements/header.ctp on line 21

I am simply using Html in my header element

Line 21: <?php echo $this->Html->link('Categories', array('controller'=>'categories') ); ?>

This Header element is calling from all views this is giving me error for some view, i don't know why but its working fine for some views.

Efforts:

  • When i change $this->Html to $this->html it works why???
  • When i tried var_dump($this->Html) it gives string(58) "�H��.

Its working in my loacal server but not in live server.

Suggest me please.

Manwal
  • 23,450
  • 12
  • 63
  • 93
  • It works because variables/objects/methods are case sensitive. Html is not the same thing as html. – EternalHour Nov 05 '14 at 07:23
  • But why `Html` working for some views? – Manwal Nov 05 '14 at 07:25
  • 1
    It seems to me, that you have Html and html defined in different places, I would search for them in your code separately. Also, based on the output from `var_dump($this->Html);` seems the encoding/charset is differing somewhere. – EternalHour Nov 05 '14 at 07:27
  • I haven't defined `Html` or `html`. and its working on local also – Manwal Nov 05 '14 at 07:32
  • you say that `$this->Html` works for some views and not for others. It's just a guess but maybe it works for some controllers and not for others. Are you sure you are calling your helper the right way in every controller? – arilia Nov 05 '14 at 07:34
  • @arilia i am sure i am calling helper form every controller. – Manwal Nov 05 '14 at 08:26
  • can you post the other lines where `Html` works? And ca you please post the line in the controller where you set the helpers, and also the line in the AppController where you set the helpers? – arilia Nov 05 '14 at 09:21

1 Answers1

-1

May be this question link to Weird PHP error: 'Can't use function return value in write context'

Perfect Answer: Because empty is not a function but a language construct (not sure), and it only takes variable

but when i change this line:

$des = (!empty(html_entity_decode($c['Coupon']['description'])))?html_entity_decode($c['Coupon']['description']):'Not Avaliable';

to

$des = html_entity_decode($c['Coupon']['description']);
$des = (!empty($des)) ? $des : 'Not Avaliable';

It works i don't know exact reason. Hope somebody help me to understand this.

Community
  • 1
  • 1
Manwal
  • 23,450
  • 12
  • 63
  • 93
  • I think this is helpful for other. can't place too much text in comment, it'll hard to understand. Its answer because it solve my issue, i think this is what answer mean @arilia – Manwal Nov 05 '14 at 09:24
  • @arilia you are not understanding my situation. So you can keep away from this. Thanks. I got my solution already – Manwal Nov 05 '14 at 11:29