如果我有一张午餐,例如www.example.com/test/example/product.html
。
我如何能够只得到测试部分(最高层)
我的理解是,你将使用<代码>。 SERVER[RequestST_URI] and maybe substr
or trim
但是,我对如何做到这一点感到沮丧,感谢你!
如果我有一张午餐,例如www.example.com/test/example/product.html
。
我如何能够只得到测试部分(最高层)
我的理解是,你将使用<代码>。 SERVER[RequestST_URI] and maybe substr
or trim
但是,我对如何做到这一点感到沮丧,感谢你!
将该插图编成一个阵列,编号<>explode,然后由您参加。
$whatINeed = explode( / , $_SERVER[ REQUEST_URI ]);
$whatINeed = $whatINeed[1];
如果你使用PHP 5.4,你可以填写$whatINeed = 爆炸(/,_SERVER[RequestST_URI]?
<?php
$url = http://username:[email protected]/test/example/product.html?arg=value#anchor ;
print_r(parse_url($url));
$urlArray = parse_url($url);
/* Output:
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /test/example/product.html
[query] => arg=value
[fragment] => anchor
)
*/
echo dirname($urlArray[path]);
/* Output:
/test
*/
进入任何道路第一部分的最简单途径是使用<代码>strtok():
echo strtok($path, / );
无论它是否拥有领先的<代码>/,都将这样做。 为做到这一点,您可提取以下途径部分:parse_url(
,并使用上述strtok(
方法:
echo strtok(parse_url($url, PHP_URL_PATH), / )
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...