-1

index.php

<?php
require_once('fr.php');
header('Location:'.abspath().directory());
?>

fr.php

<?php
require_once('functions.php');
?>

functions.php

function abspath()
{
return $_SERVER['DOCUMENT_ROOT'];
}

Now when i go to index.php, it gives me this error:-

Fatal error: Call to undefined function abspath() in C:\xampp\htdocs\index.php on line 3
hakre
  • 193,403
  • 52
  • 435
  • 836
Django Anonymous
  • 2,987
  • 16
  • 58
  • 106
  • 2
    This looks okay. Are you 1000% sure all the files are correct and up to date? – Pekka Mar 22 '12 at 12:39
  • Is your `fr.php` next to `index.php` in the folder structure? – slash197 Mar 22 '12 at 12:39
  • 1
    your require is relative to the document. is the functions.php in the same place as index.php and fr.php? – Elzo Valugi Mar 22 '12 at 12:39
  • 1
    this function is not in this .php you try to inlcude. or you order of include is not ok. First you must include it then you can use it. – senzacionale Mar 22 '12 at 12:40
  • I am using dreamweaver and can see that all files are properly linked... – Django Anonymous Mar 22 '12 at 12:42
  • 1
    The scripts posted for index.php and fr.php contain the ` – VolkerK Mar 22 '12 at 12:50
  • @VolkerK Good catch but I'd hope that would be painfully obvious to OP as it would dump the contents of functions.php to the screen before the error message – Mike B Mar 22 '12 at 12:58
  • functions.php is still a php file, so add at least the opening – Elzo Valugi Mar 22 '12 at 13:10
  • 1
    I understand that this is not the question.. but you are redirecting to a path and not to an url – mishu Mar 22 '12 at 13:11
  • @VolkerK no actually its there in my functions file i have not written it here – Django Anonymous Mar 22 '12 at 13:23
  • @mishu m unable to get you :( – Django Anonymous Mar 22 '12 at 13:24
  • 1
    @AbhilashShukla if you found the problem then you can ignore me :) what I was referring to is the fact that $_SERVER['DOCUMENT_ROOT'] usually is a **path** (see here http://de.php.net/manual/en/reserved.variables.server.php) if you don't change the value.. and setting the location header is a way to redirect to an **url**; notice path vs. url (eg: C:\xampp\htdocs\ vs http:/ /localhost) – mishu Mar 22 '12 at 13:45
  • @mishu Actually things resolved but what you said is a great insight.... and definitely i might have come with this problem next day... thanks for the help and support :) – Django Anonymous Mar 22 '12 at 14:33

1 Answers1

0

Hey all my commenting people were right... i don't know why it happened but when i restarted my xampp it worked fine for me :)

So this is 100% correct

index.php

<?php
require_once('fr.php');
header('Location:'.abspath().directory());
?>

fr.php

<?php
require_once('functions.php');
?>

functions.php

function abspath()
{
return $_SERVER['DOCUMENT_ROOT'];
}
Django Anonymous
  • 2,987
  • 16
  • 58
  • 106