0

Is it possible to input the string from the url in the code.

"http://website.com?ip=123.com"

 $statut = file_get_contents('http://www.example.com/index.php?Etat_Query&ip=',$ip,'&port=25565');

i want $ip to be replaced with the variable 123.com from the URL.

(Sorry my english is not the best)

2
  • 2
    Are you just looking for $_GET['ip']? Commented Nov 3, 2015 at 23:05
  • , should be . to connect two strings. Otherwise the simple answer to your question is yes it's possible Commented Nov 4, 2015 at 3:06

1 Answer 1

1

Of course it is possible but you have to URL Encode your ip variable in the URL using this :

$encoded = urlencode('123.com');

For your specific example it's not necessary but if the URL is more complicated (like using '&'...) it will be necessary.

Then your $ip variable would just be :

$ip = $_GET['ip'];

Let me just warn you about a security issue that could occur using this method, like malicious php script that could be downloaded to your server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.