Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 0.53 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I make include use local directories in php
  2. <?php
  3. $path_of_this_script = dirname(__FILE__);
  4. [...]
  5.        
  6. <?php
  7. function include_image() {
  8.   $image_url = "icon.png"; // Will search for icon.png in "files" directory
  9.   //do something with $image_url
  10. }
  11. ?>
  12.        
  13. <?php
  14. $image_path = "http://www.example.com/images"; // or "foldername/subfoldername/images"
  15. ?>
  16.        
  17. <?php
  18. include "vars.php";
  19. function include_image() {
  20.   $image_url = "$image_path/icon.png"; // Will search for icon.png in "files" directory
  21.   //do something with $image_url
  22. }
  23. ?>