0

Hi I writed a test code as below.

<?php
$url = 'http://localhost/events/result/cn_index.php?login';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);


?>

Output

Array ( [scheme] => http [host] => localhost [path] => /events/result/cn_index.php [query] => login ) /events/result/cn_index.php

Now I inserted the line below

echo array[query]; // I want to echo 'login', but failed.

How to get the value of 'login'?

2 Answers 2

2
$parsed = parse_url($url);
echo $parsed['query'];
Sign up to request clarification or add additional context in comments.

Comments

2

Try with:

$output = parse_url($url, PHP_URL_PATH);
echo $output['query'];

2 Comments

@hsz, Tested with your code, but Output / on my winxp XAMPP dev environment. Thank you.
So in $output['query'] is just / ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.