What is the difference between include() and require() ?

They are almost the same thing. The differences are if you use require and the file you are requiring doesnt exist, php will give you a fatal error and will stop loading the page. if you use include, it will just give you a warning error but will continue with the rest of the script, and also any file using require() cannot return a value, so using include() is better.

require (or require_once) is usually used when you have database connections in seperate files. This stops it duplicating any connections

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.