PHP question

I have this block of code

<?php
echo $html->css(
      '/hp_events/css/ftaf2',
      'stylesheet',
      array( 'media' => 'screen'));
?>

A coder told me to convert it using $this->html->css - but I am not sure if I am following what he means. can anyone help?
lvollmerAsked:
Who is Participating?
 
nanharbisonCommented:
Have you tried this with a capital H in Html? Is this cakephp?
<?php
echo $this->Html->css(
      '/hp_events/css/ftaf2',
      'stylesheet',
      array( 'media' => 'screen'));
?>

Open in new window

0
 
Chad SmithSoftware EngineerCommented:
echo $this->html->css(
      '/hp_events/css/ftaf2',
      'stylesheet',
      array( 'media' => 'screen'));
0
 
lvollmerAuthor Commented:
when I try that, i get this error:
Fatal error: Call to a member function css() on a non-object
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
nanharbisonCommented:
I think the coder meant for you to put $this in from of the code, see below
<?php
echo $this->html->css(
      '/hp_events/css/ftaf2',
      'stylesheet',
      array( 'media' => 'screen'));
?>

Open in new window

0
 
lvollmerAuthor Commented:
that is what i first thought, but when i use that code i still get that error
0
 
nanharbisonCommented:
this code is from calling a class, can you show us the class?
0
 
nanharbisonCommented:
maybe it is  $this->css ? And what is the error message you are getting?
0
 
lvollmerAuthor Commented:
Fatal error: Call to a member function css() on a non-object
0
 
nanharbisonCommented:
Oh duh, right, you did say that. Can we see the class?
0
 
lvollmerAuthor Commented:
im trying to figure out how to find that
0
 
nanharbisonCommented:
Are you on a CMS, or custom coded website?
0
 
PragmatiCoderCommented:
Any chance that you are working with a cakePHP site? are you trying that code inside a view (a .ctp file)?
0
 
lvollmerAuthor Commented:
yes this is cakephp and it is a .ctp template
0
 
lvollmerAuthor Commented:
the cap H worked - thanks! and yes this was cakephp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.