Jump to content

how to define a serten folder with PHP ''define''?...


Recommended Posts

hello all from w3s again... i have seemed the PHP word ''Define''. now my questio is. if i have 2 files in my root, and 3 files in a folder called include, and one of those inside include folder is called main_design.php. and called by 2 functions like so inside all the other files inside root...:

function stdhead($title = "",$css_file = ""){$stdhead_start = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html'; charset=iso-8859-1' /><link rel='stylesheet' type='text/css' href='styles/".$css_file.".css'/><link rel='shortcut icon' href='fav_icon.ico' /><title>".$title."</title></head><body><table class='banner_table' align='center' cellpadding='0'><tr><td><a href='index.php'><img src='styles/images/banners/banner.png' width='1000' height='140' alt='SS_2012' /></a></td></tr></table> <table class='menu_table' border='0' align='center'><tr><td class='navigation'><a href='index.php'>HOME</a></td><td class='navigation'><a href='browse.php'>TORRENTS</a></td><td class='navigation'><a href='index.php'>REQUESTS</a></td><td class='navigation'><a href='index.php'>BECOME UPLOADER</a></td><td class='navigation'><a href='index.php'>CHAT</a></td><td class='navigation'><a href='index.php'>FORUM</a></td><td class='navigation'><a href='index.php'>GUIDES</a></td><td class='navigation'><a href='index.php'>BONUS</a></td><td class='navigation'><a href='index.php'>RULES</a></td><td class='navigation'><a href='index.php'>FAQ</a></td><td class='navigation'><a href='index.php'>LINKS</a></td><td class='navigation'><a href='index.php'>SUPPORT</a></td></tr></table> <table class='main_table' align='center'><tr><td>";return $stdhead_start;}//stdhead ends...  function stdfooter(){$stdfoot_start ="</td></tr></table>  <table class='foot_table' align='center'>  <tr>   <td>Speed-Scene © 2012 -> Revision 01</td>  </tr>  </table>   </body>  </html>";return $stdfoot_start;}//stdfooter ends...

and root files ect;

<?phprequire_once("include/bittorrent.php");echo stdhead("Home","1");?>This is the Index Page!...<?phpecho stdfooter();?>

now my question is, that if i have an another file inside include called config.php. and wish to make a define inside there... and after that, call it on one of the root files, so it would go inside the include folder, and then i just need to write the name of the file i need to have ect... how do i do this?... thanks in advance!

Link to post
Share on other sites

What do you mean by "define"? If you have a folder inside include/ and you want to use a file that's there, then put the path to the file:

require_once('include/new_folder/file.php');

Link to post
Share on other sites

sorry for not explaining this in details, im still confuced myself, and yeah.. i could use the require_once orr include... but i needed to try somfthing diffrent, so that is why i asked :)... like if i need it inside a long code, it would be nice to write (ROOT_INC),ect... just seemed it alot of places, just how to write it.. and yeah bb.. i did see this, but only on how to use it on number and such, but is it the same writing style?... EDIT: just a fast question, if i was going to write this... could i write like this:

define("ROOT","include/");echo ROOT."config.php";

if so?...

Edited by rootKID
Link to post
Share on other sites

yes you can do like that. define() not only can take value as integer it can be any scalar types or even expressions. the constant will be available in your global scope of your script.

Link to post
Share on other sites
Guest So Called

Your question is totally lost on me. I have no idea what you're asking.

define("ROOT","include/");echo ROOT."config.php";

That will echo "include/config.php" to the visitor's browser. I have no idea why you want to tell your visitor what you want to include instead of actually including the code.

Link to post
Share on other sites

my question was if i could make a define like that (@so called). and birbal answered me on that part :)... so, that is pretty much it guys, thanks for the clear up in my mind :)...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...