How to import libraries in PHP

I am usually an Asp.NET developer who wants to switch to PHP. I have quite a lot of time to learn it, and I wonder how to use libraries in PHP?

Do I need to use requireor includeto import the library into my project to use classes, functionsetc., defined in the library? Or something else.

I am running php on an Apache server that I found for Zend Server, and it looked weird for me.

Can someone explain to me the general steps to import and start using libraries in my own code?

Thank.

+3
source share
1 answer

You can use both.

The request will cause a fatal error if the file is not found.

require('lib.class.php');

You can use include if you need to continue the script, even if the file cannot be loaded.

how

 if (!include('lib')) {
   doWhatever();
 }
+6
source

All Articles