help with echoing out the url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moroccanplaya
    New Member
    • Jan 2011
    • 80

    help with echoing out the url

    hi this should work but i do not know why its not working


    Code:
    $url = $_GET['url'];
    echo $url;
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What do you mean by not working? Are there error messages? If so, what are they? Is it not printing out the value that was passed? If so, what value was passed and what did it print instead?

    Comment

    • moroccanplaya
      New Member
      • Jan 2011
      • 80

      #3
      Code:
      <?php
      
      $url = $_GET["url"];
      echo $url;
      
      
      require 'controllers/' .$url;
      
      $controller = new $url;
      
      
      
      ?>
      Code:
      <?php
      class Index {
          
          function __construct() {
              
              echo 'we are in index'; 
          }
      }
      
      ?>
      error:

      ( ! ) Notice: Undefined index: url in C:\wamp\www\mvc \index.php on line 3
      Call Stack
      # Time Memory Function Location
      1 0.0008 364448 {main}( ) ..\index.php:0

      ( ! ) Warning: require(C:\wamp \www\mvc\contro llers) [function.requir e]: failed to open stream: Permission denied in C:\wamp\www\mvc \index.php on line 7
      Call Stack
      # Time Memory Function Location
      1 0.0008 364448 {main}( ) ..\index.php:0

      ( ! ) Fatal error: require() [function.requir e]: Failed opening required 'controllers/' (include_path=' .;C:\php\pear') in C:\wamp\www\mvc \index.php on line 7
      Call Stack
      # Time Memory Function Location
      1 0.0008 364448 {main}( ) ..\index.php:0

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Looks like the errors stem from line 3 and cascade downwards. It's saying that the url variable isn't being passed in GET. Look at the form that is submitted and make sure there's a form control with the name url.

        Comment

        Working...