James Wilson
James Wilson

Reputation: 809

Can I define my classes separately if my classes are all in common.php

I would like to do the following:

<?php

session_start();

require_once "../includes/common.php";

$quoteShared = new quoteShared();

?>

common.php has:

<?php
require_once "../objects/quote/shared.php";
... plus many others
?>

This gives me the error of:

Fatal error: Class 'quoteShared' not found

I want to define classes separately to where I include them so I use the specific ones I need on different pages. Can it be done?

Upvotes: 0

Views: 39

Answers (1)

ildanno
ildanno

Reputation: 119

That's a bad design strategy, you should take a look here: http://php.net/manual/en/language.oop5.autoload.php

Upvotes: 1

Related Questions