I am normally an ASP.NET developer who wants to migrate to PHP. I am taking quite a time to learn it and I am wondering how to use libraries in PHP?
Do I need to use require
or include
to import a library into my project to use the classes
, functions
etc. defined in the library? Or something else.
I running PHP on the Apache web server what I've found is for Zend Server and it looked weird to me.
Can someone explain me overall steps to import and start using libraries in my own code?
Thanks.
You can use both.
Require will throw a fatal error if the file is not found.
require('lib.class.php');
You could use include if you need to continue the script even if the file couldn't get loaded.
Like:
if (!include('lib')) {
doWhatever();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With