Need quick php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    Need quick php script

    If url = www.mysite.com/page.php
    $Page = page.php

    In that case I can put something like:
    www.mysite.com/archive/<?php echo$page;?>archive3.php

    Can someone do this for me quickly? In a nutshell, it is basically making a variable of the page name. (page.php)

    Thanks!
  • woj
    <&(©¿©)&>
    • Jul 2002
    • 47882

    #2
    try this perhaps? ->
    $page = $_SERVER['REQUEST_URI'];
    Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
    Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
    Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

    Comment

    • mkx
      Confirmed User
      • Nov 2003
      • 4001

      #3
      thanks woj, let me give that a whirl

      Comment

      • mkx
        Confirmed User
        • Nov 2003
        • 4001

        #4
        Displays "/test.php" I only want it to display "test" Sorry my fault for typing it wrong above
        Last edited by mkx; 08-13-2005, 03:49 PM.

        Comment

        • woj
          <&(©¿©)&>
          • Jul 2002
          • 47882

          #5
          $page = basename($_SERVER['REQUEST_URI']); (?)
          Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
          Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
          Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

          Comment

          • mkx
            Confirmed User
            • Nov 2003
            • 4001

            #6
            That displays test.php without the / so it needs to just remove the .php

            Comment

            • LazyD
              Confirmed User
              • Aug 2004
              • 102

              #7
              $parts = explode(".", basename($_SERVER['REQUEST_URI']));

              => $parts[0] = test
              => $parts[1] = php
              Calidi studio
              http://www.calidi.com
              ICQ: #18466283

              Comment

              • mkx
                Confirmed User
                • Nov 2003
                • 4001

                #8
                Originally posted by LazyD
                $parts = explode(".", basename($_SERVER['REQUEST_URI']));

                => $parts[0] = test
                => $parts[1] = php
                Parse error: parse error, unexpected T_DOUBLE_ARROW in /home/pornpar/public_html/test.php on line 4

                Comment

                • budz
                  Disruptive Innovator
                  • Sep 2003
                  • 4230

                  #9
                  Originally posted by woj
                  $page = basename($_SERVER['REQUEST_URI']); (?)
                  Originally posted by mkx
                  That displays test.php without the / so it needs to just remove the .php

                  PHP Code:
                  $page = str_replace(".php", "", $page); 
                  
                  C:\Code\
                  C:\Code\Run\

                  Comment

                  • woj
                    <&(©¿©)&>
                    • Jul 2002
                    • 47882

                    #10
                    $page = basename($_SERVER['REQUEST_URI'],'.php'); (?)
                    Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
                    Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
                    Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

                    Comment

                    • mkx
                      Confirmed User
                      • Nov 2003
                      • 4001

                      #11
                      Originally posted by woj
                      $page = basename($_SERVER['REQUEST_URI'],'.php'); (?)
                      Works perfect, thanks! One last thing, any chance that it can display "Test" instead of "test" first letter caps

                      Comment

                      • LazyD
                        Confirmed User
                        • Aug 2004
                        • 102

                        #12
                        Originally posted by mkx
                        Parse error: parse error, unexpected T_DOUBLE_ARROW in /home/pornpar/public_html/test.php on line 4
                        nonono

                        What I wanted to say is that after "exploding" the string into an array, the variable $parts[0] will contain "test" and variable $parts[1] will contain "php".
                        Calidi studio
                        http://www.calidi.com
                        ICQ: #18466283

                        Comment

                        • woj
                          <&(©¿©)&>
                          • Jul 2002
                          • 47882

                          #13
                          Originally posted by mkx
                          Works perfect, thanks! One last thing, any chance that it can display "Test" instead of "test" first letter caps
                          $page = ucfirst(basename($_SERVER['REQUEST_URI'],'.php'));
                          Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
                          Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
                          Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

                          Comment

                          • mkx
                            Confirmed User
                            • Nov 2003
                            • 4001

                            #14
                            Originally posted by LazyD
                            nonono

                            What I wanted to say is that after "exploding" the string into an array, the variable $parts[0] will contain "test" and variable $parts[1] will contain "php".
                            sorry i am a php n00b

                            Comment

                            • mkx
                              Confirmed User
                              • Nov 2003
                              • 4001

                              #15
                              Originally posted by woj
                              $page = ucfirst(basename($_SERVER['REQUEST_URI'],'.php'));
                              Did I ever tell you how much I love you?

                              Thank you all!

                              Comment

                              Working...