うーん、比較するだけ?
if ('www.mydomain.com/greenapples' === $myurl) {
echo 'green apples!';
}
アップデート
詳細な情報がなければ、これがあなたの質問に当てはまるかどうかわかりませんが、URL の最後の部分だけに関心があり、 URL にクエリ文字列 (例: ) が含まれている可能性を考慮している場合は、次の?foo=bar&bar=foo
ようなものを試してください。これ:
// NOTE: $myurl should be INCLUDING 'http://'
$urlPath = parse_url($myurl, PHP_URL_PATH);
// split the elements of the URL
$parts = explode('/', $urlPath);
// get the last 'element' of the path
$lastPart = end($parts);
switch($lastPart) {
case 'greenapples':
echo 'green!';
break;
case 'greenapplesandpears':
echo 'green apples AND pears!';
break;
default:
echo 'Unknown fruit family discovered!';
}
ドキュメンテーション:
http://www.php.net/manual/en/function.parse-url.php
http://php.net/manual/en/function.end.php
http://php.net/manual/en/control-structures.switch.php