Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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'); "