Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page Basic Markup for WordPress Settings Pages

Anthony Lucio
Anthony Lucio
20,431 Points

At 3:10, is it best to 'require'?

Referencing a document. Is that considered best practice?

2 Answers

Anthony,

This may or may not answer your question but speaking as a PHP developer, you can either use include or require when you want to include another script to your current one. The big difference is that require will error out and terminate the script if the file you are trying to require doesn't exist. Include doesn't. If you need the included script in order for your current script to function, you would use require. I mostly use require (require_once if I want to make sure the included script doesn't get included more than once). You can use either or but if you are going to be including files that may be dependent, you might as well use require. There really isn't that much of a difference. Hope this helps.

Cheers!

simasimona
simasimona
747 Points

'require' didn't work for me. I used " include( plugin_dir_path( FILE ) . 'inc/options-page-wrapper.php'); "