Jump to content

Classes dont work on local machine work when uploaded why?


CStrauss
 Share

Recommended Posts

I got a class that generates the meta tags in my header section. but for some reason when i test on my local machine i get this fatal error.Fatal error: Cannot instantiate non-existent class: meta in C:\wamp\www\Test\layout.php on line 4When I upload pages to server everything works find no fatal error occurs.is there something that perhaps i need to reset in my config files to accept classes now? I have never had this problem before so im thinking something got changed around in my config files.Here is my code. I'm Positive the code is valid cause it works on my sever but perhaps people see something I don't thats not making it work correctly on my local machine.class being called

<?class meta{   function metadata($ptitle){		      // Formulate the description for each page.      if(empty($ptitle)){         $description = $this->description;      } else {         $description = "$ptitle - $this->description";      }		      // Make the keywords of the title lower case      $keywords = strtolower($ptitle);      // Remove extra spaces      $keywords = str_replace("  ", " ", $keywords);      // Make string comma seperated      $meta_words = str_replace(" ", ", ", $keywords);            // If no Page Title, Use Alternative      if(empty($ptitle)){         $meta = "<title>$this->sitename - $this->slogan</title>\n";      } else {         $meta = "<title>$this->sitename: $ptitle</title>\n";      }            // Append meta content to the $meta string for output      $meta .= "<meta name=\"KEYWORDS\" content=\"$meta_words, $this->keywords2\"  />\n";      $meta .= "<meta name=\"DESCRIPTION\" content=\"$this->description\" />\n";      $meta .= "<meta name=\"ROBOTS\" content=\"INDEX,FOLLOW\" />\n";      $meta .= "<meta name=\"GENERATOR\" content=\"$this->company_name\" />\n";      $meta .= "<meta name=\"AUTHOR\" content=\"$this->company_name\" />\n";      $meta .= "<meta name=\"REVISIT-AFTER\" content=\"2 DAYS\" />\n";      $meta .= "<meta name=\"RESOURCE-TYPE\" content=\"document\" />\n";      $meta .= "<meta name=\"COPYRIGHT\" content=\"Copyright © 2003 $this->company_name\" />\n";      $meta .= "<meta name=\"DISTRIBUTION\" content=\"Global\" />\n";      $meta .= "<meta name=\"GENERATOR\" content=\"$this->generator\" />\n";      $meta .= "<meta name=\"RATING\" content=\"GENERAL\" />\n";      $meta .= "<meta HTTP-EQUIV=\"reply-to\" content=\"webmaster@abc.com\" />\n";      $meta .= "<meta HTTP-EQUIV=\"content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";      return $meta;   }}?>

The layout page that includes the common file that includes the classes

<?php	include $_SERVER['DOCUMENT_ROOT'].'/common.php';	function myheader($ptitle){	$meta = &new Meta;	$meta->company_name = "www.something.com";	$meta->description = "Descriptsion here";	$meta->keywords2 = "key,words,here";	$meta->sitename = "My Website";	$meta->slogan = "Our Slogan";	$meta->generator = "PHP, Dreamweaver MX";	?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><?php echo $meta->metadata($ptitle); ?></head><body><?php	 } // CLOSE myheader()function footer(){ ?></body></html><?php } ?>

now when i display the page all it shows is this:description; } else { $description = "$ptitle - $this->description"; } // Make the keywords of the title lower case $keywords = strtolower($ptitle); // Remove extra spaces $keywords = str_replace(" ", " ", $keywords); // Make string comma seperated $meta_words = str_replace(" ", ", ", $keywords); // If no Page Title, Use Alternative if(empty($ptitle)){ $meta = "\n"; } else { $meta = "\n"; } // Append meta content to the $meta string for output $meta .= "keywords2\" />\n"; $meta .= "description\" />\n"; $meta .= "\n"; $meta .= "company_name\" />\n"; $meta .= "company_name\" />\n"; $meta .= "\n"; $meta .= "\n"; $meta .= "company_name\" />\n"; $meta .= "\n"; $meta .= "generator\" />\n"; $meta .= "\n"; $meta .= "\n"; $meta .= "\n"; return $meta; } } ?>Fatal error: Cannot instantiate non-existent class: meta in C:\wamp\www\Test\layout.php on line 4so for some reason its displaying my code in my class file instead of using it. This is really frustrating me cause im hating to have to work code and upload it to test it and what not but until i figure out why i can't use my classes i cant test code on my local machine for the obvious reasons. Thanks in advance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...