Some examples of PHP pseudo-static implementation code

Source: Internet
Author: User
  1. Pseudo-static method one
  2. Localhost/jbxue/test.php?id|1@action|2
  3. $PHP 2html_fileurl = $_server["Request_uri"];
  4. echo $Php 2html_fileurl. "
    ";///jbxue/test.php?id|1@action|2
  5. $PHP 2html_urlstring = Str_replace ("?", "" ", Str_replace ("/"," ", STRRCHR (STRRCHR ($Php 2html_fileurl,"/"),"? "));
  6. echo $Php 2html_urlstring. "
    ";//Id|1@action|2
  7. $PHP 2html_urlquerystrlist = explode ("@", $Php 2html_urlstring);
  8. Print_r ($Php 2html_urlquerystrlist);//Array ([0] = id|1 [1] = action|2)
  9. echo "
    ";
  10. foreach ($Php 2html_urlquerystrlist as $Php 2html_urlquerystr)
  11. {
  12. $PHP 2html_tmparray = explode ("|", $Php 2HTML_URLQUERYSTR);
  13. Print_r ($Php 2html_tmparray);//Array ([0] = = ID [1] + 1); Array ([0] = = action [1] = 2)
  14. echo "
    ";
  15. $_get[$Php 2html_tmparray[0]] = $Php 2html_tmparray[1];
  16. }
  17. Echo ' false static: $_get variable
    ';
  18. Print_r ($_get); Array ([id|1@action|2] = [id] = 1 [action] + 2)
  19. echo "
    ";
  20. echo "";
  21. Echo $_get[id]. "
    ";//1
  22. Echo $_get[action];//2
  23. ?>
Copy Code

Code 2,

  1. Pseudo-static method two
  2. Localhost/jbxue/test.php/1/2
  3. $filename = basename ($_server[' script_name ');
  4. echo $_server[' Script_name ']. "
    ";///jbxue/test.php
  5. echo $filename. "
    ";//test.php
  6. if (Strtolower ($filename) = = ' test.php ') {
  7. if (!emptyempty ($_get[id])) {
  8. $id =intval ($_get[id]);
  9. echo $id. "
    ";
  10. $action =intval ($_get[action]);
  11. echo $action. "
    ";
  12. }else{
  13. $nav =$_server[' Request_uri '];
  14. echo "1:" $nav. "
    ";///JBXUE/TEST.PHP/1/2
  15. $script =$_server[' Script_name '];
  16. echo "2:" $script. "
    ";///jbxue/test.php
  17. $nav =ereg_replace ("^ $script", "", UrlDecode ($nav));
  18. echo $nav. "
    "; /1/2
  19. $vars =explode ("/", $nav);
  20. Print_r ($vars);//Array ([0] = [1] = 1 [2] = 2)
  21. echo "
    ";
  22. $id =intval ($vars [1]);
  23. $action =intval ($vars [2]);
  24. }
  25. echo $id. ' & '. $action;
  26. }
  27. ?>
Copy Code

1 2 Next last page

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.