How to obtain the parameters in the URL php

https://zhidao.baidu.com/question/140978452.html

 

For example, there is a site at

http: // /goods.php?u=59&id=24#pinglun domain

I want to get the id value

You can then, be used for analyzing the positive function to the array php

Regular use can do

preg_match ( '/ id = (\ d +) /', $ _ SERVER [ "REQUEST_URI"], $ m); // $ _ SERVER indicates that the current URL url

print_r($m[1]);exit;

Or function by parse_url () and by parse_str ()

$cur_q=parse_url($_SERVER["REQUEST_URI"],PHP_URL_QUERY);

parse_str($cur_q,$myArray);

print_r($myArray["id"]);exit;

Expand information

PHP (English name: PHP: Hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a versatile open source scripting language. Syntax absorbed the C language, Java, and Perl features conducive to learning, widely used, mainly for Web development. PHP syntax unique mix of C, Java, Perl and PHP own syntax. It can perform dynamic than the CGI or Perl pages more quickly. Compared with dynamic PHP pages made with other programming languages, PHP is embedded into HTML program (an application under the Standard Generalized Markup Language) document to execute, execute efficient than completely CGI generated HTML markup is much higher; PHP can also be performed after the compiled code, the compiler can optimize the code to achieve encryption and run, make the code run faster.

PHP features include:

1. PHP syntax unique mix of C, Java, Perl and PHP syntax from innovation.

2. PHP can execute faster than CGI dynamic web pages or Perl - dynamic pages, compared with other programming languages,

PHP is embedded into the HTML document procedures to execute, perform more efficient than completely CGI generated htmL tag is much higher;

PHP has a very powerful, all CGI PHP function can be realized.

3. PHP supports almost all popular databases and operating systems.

4. The most important thing is PHP program can be extended with C, C ++!

References : Baidu Encyclopedia PHP

Guess you like

Origin blog.csdn.net/james_laughing/article/details/92778665