Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Php_self

  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php_self

    <FORM METHOD="POST" ACTION="<? echo $_SERVER['PHP_SELF']; ?>">


    if i have this code in my CallerFile.php
    is it similar to
    <FORM METHOD="POST" ACTION="CallerFile.php">
    ???

    if not may i know the differences
    if yes which is better?

    sujith

  • #2
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes it's the same
    $SERVER['PHP_SELF'] is a superglobal which contains the page which is opened.
    So in your case : if you visit callerfile.php
    $SERVER['PHP_SELF'] will automaticly get the url visited, so in this case it will contain : /callerfile.php

    This variable is usefull when you create installscripts. If people then install your script in the directory 'newscript/'
    you should change your link of every form to /newscript/callerfile.php but with the $server['php_self'] it automaticly posts to the page /newscripts/callerfile.php


    I hop this is clear because i'm not a good explainer

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Shouldn't that be $_SERVER['PHP_SELF'] (i.e. dollar underscore …)

  • #4
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes sorry forgot to typ it lol


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •