PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

[FIXED] PHP : I need to read value from ur "www.smple.com/sample.php/value in php

 February 28, 2022     lamp, php, wamp, xampp     No comments   

Issue

I need to read the value from url in php code. Below is the sample url . I am passing the value after php file name. I know that we can use query string like "www.smple.com/sample.php?name=value"

But requirement is url need to filename/value, this value will be dynamic. Please any one can help me to solve this issue.

URL : www.smple.com/sample.php/value


Solution

Use parse_url to get the path from the URL and then use explode to split it into its segments.

$uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri_segments = explode('/', $uri_path);

echo $uri_segments[1];


Answered By - sonam gupta
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing