Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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?
0
lvollmer
Asked:
lvollmer
1 Solution
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now