3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

When using PHP, does it matter where you place the code?

Might seem like a silly question but is it better to place all your PHP code at the top of the page, then echo it where you want it to be, or to keep the code all in one spot?

For example,
Option One:

<?php code goes here at the top ?>

[rest of webpage]

<h2><?php echo ' $random_thing' ?></h2>

Option Two:

<php connect blah blah select blah;
 echo ' $random_thing';
?>

Hopefully that makes sense...

2 answers
May 25, 2011. 11:43 PMLithium Rain says:
I adhere to the school of thought that scattering any type of code throughout html is less than optimal and often makes for ugly, hard-to-fix code (not that it's a hard-and-fast rule for all case, though).
May 22, 2011. 8:28 AMJayefuu says:
I never bother. And sometimes you need input from the user.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!