Fatal error: Call to a member function Animate() on a non-object in jquery.php on line 38

getting: Fatal error: Call to a member function Animate() on a non-object in jquery.php on line 38


<?php

class Jquery {
      
      function animate($trigger, $element, $event, $time) {
            
            echo "<script>
            
                    $(function() {
                        
                        $('$trigger').$event(function() {
                        
                        $('#$element').slideDown($time);
            
                        });
                        
                      });
   
                  </script>";
            
            ;
      }
}

?>



<?

$trigger= "a";
$element = "paragraph";
$event = "hide";
$time = "500";

$slide = new Jquery();

$slide1->animate($trigger, $element, $event, $time);



?>


<html>
   
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <title>jquery class</title>
       
    </head>
   
   
   
   
   
</html>
ninjadude12Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tsmgeekCommented:
you
$slide = new Jquery();

$slide1->animate($trigger, $element, $event, $time);

Open in new window


note the error with $slide1->animate when it should be $slide->animate
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
I think tsmgeek is on the right track here.

If you add error_reporting(E_ALL) to the top of all your scripts, you will get a notice when you try to use an undefined variable.  It will save you from a lot of headscratching over something as simple as a typographical error or a misspelling like this one.

The code snippet shows how to create the error and shows how different error reporting levels can give you different results.  You can test it here:
http://www.laprbass.com/RAY_oop_example_2.php
<?php // RAY_oop_example_2.php
error_reporting(E_ALL);
echo "<pre>" . PHP_EOL; // MAKE IT EASY TO READ THE OUTPUT


// DEMONSTRATE HOW PHP HANDLES UNDEFINED VARIABLES (PROPERTIES)
// AND UNDEFINED FUNCTIONS (METHODS) IN OOP NOTATION.
// NOTE HOW DIFFERENT ERROR REPORTING LEVELS WILL CAUSE DIFFERENT OUTPUT
// MAN PAGE http://php.net/manual/en/language.oop5.php


// DEFINE A CLASS OF TEST DATA
class Thing
{
    // DEFINE SOME PROPERTIES
    public $p1, $p2, $p3;

    // DEFINE A CONSTRUCTOR TO SET THE VALUES OF THE PROPERTIES
    public function __construct()
    {
        $this->p1 = 'One';
        $this->p2 = 'Two';
        $this->p3 = 'Three';
    }
}


// INSTANTIATE AN OBJECT FROM THE Thing CLASS
$x = new Thing;
if (is_object($x)) echo PHP_EOL . "X IS AN OBJECT ";


// SHOW THE CONTENTS OF THE OBJECT
var_dump($x);

// ITERATE OVER THE OBJECT
foreach ($x as $property => $value)
{
    echo PHP_EOL . "$property CONTAINS $value";
}


// FOR CONTRAST, CREATE A NON-OBJECT
$y = array();
if (is_array($y)) echo PHP_EOL . "Y IS AN ARRAY ";

// TRY TO ACCESS A PROPERTY OF A NON-OBJECT
echo PHP_EOL . 'HERE IS Y->PROP' . $y->prop;

// SET THE DEFAULT ERROR REPORTING AND TRY IT AGAIN - NO "NOTICE" SHOWS
error_reporting(E_ALL ^ E_NOTICE);
echo PHP_EOL . 'HERE IS Y->PROP' . $y->prop;

// NOW TRY TO ACCESS A METHOD OF A NON-OBJECT
echo PHP_EOL . $y->test();

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.