Hey everyone,

I just started learning PHP a few weeks ago and I have a question about classes. In Python you can import classes from other documents so that you can use them in your new document without having to write the class again in the new document. How is this done in PHP? Is there any kind of import function for classes?

Save your class in a file and include it into another page the same as you would any php content.
Example: you have a class Car saved in a file called car.php

require_once 'car.php';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.