Announcement

Collapse
No announcement yet.

is there a php code for this

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • is there a php code for this

    is there a code in php similiar to asp's code to check whether or not the current page's url matches a certain string (extremely usefull for conditional includes)

    or is there something that will give me the refering url in a string so i can block out certain requests for a page if the refering page doesn't match what i want?

  • #2
    Your probally wanting $PHP_SELF and $HTTP_REFERER

    Hope this helps
    ~Chris

    Comment


    • #3
      I'm new to php but I use the following code snippet to determine the current filename (under Apache only, I believe):

      <?php

      /***************************************
      ** Get environment variables.
      ***************************************/

      $full_path = getenv("REQUEST_URI");

      /***************************************
      ** Evaluate base path's existence,
      ** get filename and compensate for
      ** hidden index.html file.
      ***************************************/

      $dot_pos = strpos($full_path, ".");
      if ($dot_pos == false) {
      $base = $full_path;
      $page_file = "index.html";
      }
      else {
      $base = dirname($full_path);
      $page_file = basename($full_path);
      }

      ?>
      Ramses - René-Marc Simard
      SciFlicks SQUAD! Forums
      SciFlicks.com - Science Fiction Cinema

      Comment


      • #4
        $PHP_SELF refers to the current filename. It is commonly used when you will call the file from itself to pass variables so that a user can change the filename without having to change the code.

        Comment


        • #5
          thanks

          this was exactly what i was looking for.

          Comment


          • #6
            hrmm

            $HTTP_REFERER doesn't seem to work, is this compatible with php3?

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X