Jump to content

How do i include a file which has class in it?


Perad

Recommended Posts

OK, this sounds like a stupid question and probably is.

 

I have two files, file 1 has the classes.

 

class Name {

 

} etc

 

 

File 2 has what i want to do with the class.

 

It starts with

 

require '../blogclass.php';

 

However, instead of implementing the class it is just displaying all the public parts of the class... does anyone know why this is happening?

//file 1

<?php
$name = new Name(); // initiate class here ???
class Name {

}
?>

 

// file2

<?php
require_once('../blogclass.php'); // to avoid double instantiation.

print_r($name, true); // should print out the class object for testing
?>

 

Is that what you are looking for?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.