file_get_contents() not working for 2 url's
up vote
0
down vote
favorite
I am using file_get_contents()
function to get two webpages from Google. My code is:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=ice&start=00'))));
The file_get_contents
function works for the first URL but it does not work for second URL. What's the problem?
php file-get-contents
add a comment |
up vote
0
down vote
favorite
I am using file_get_contents()
function to get two webpages from Google. My code is:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=ice&start=00'))));
The file_get_contents
function works for the first URL but it does not work for second URL. What's the problem?
php file-get-contents
Is my answer ok?
– jiwopene
Nov 12 at 16:33
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using file_get_contents()
function to get two webpages from Google. My code is:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=ice&start=00'))));
The file_get_contents
function works for the first URL but it does not work for second URL. What's the problem?
php file-get-contents
I am using file_get_contents()
function to get two webpages from Google. My code is:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=ice&start=00'))));
The file_get_contents
function works for the first URL but it does not work for second URL. What's the problem?
php file-get-contents
php file-get-contents
edited Nov 11 at 5:14
jiwopene
1688
1688
asked Nov 10 at 21:13
Alireza Eftekhari
62
62
Is my answer ok?
– jiwopene
Nov 12 at 16:33
add a comment |
Is my answer ok?
– jiwopene
Nov 12 at 16:33
Is my answer ok?
– jiwopene
Nov 12 at 16:33
Is my answer ok?
– jiwopene
Nov 12 at 16:33
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It is because there is character, that can't be processed by htmlspecialchars
. file_get_contents
is working.
Try ENT_SUBSTITUTE
option:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
https://secure.php.net/manual/en/function.htmlspecialchars.php
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It is because there is character, that can't be processed by htmlspecialchars
. file_get_contents
is working.
Try ENT_SUBSTITUTE
option:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
https://secure.php.net/manual/en/function.htmlspecialchars.php
add a comment |
up vote
0
down vote
It is because there is character, that can't be processed by htmlspecialchars
. file_get_contents
is working.
Try ENT_SUBSTITUTE
option:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
https://secure.php.net/manual/en/function.htmlspecialchars.php
add a comment |
up vote
0
down vote
up vote
0
down vote
It is because there is character, that can't be processed by htmlspecialchars
. file_get_contents
is working.
Try ENT_SUBSTITUTE
option:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
https://secure.php.net/manual/en/function.htmlspecialchars.php
It is because there is character, that can't be processed by htmlspecialchars
. file_get_contents
is working.
Try ENT_SUBSTITUTE
option:
var_dump(htmlspecialchars(html_entity_decode(file_get_contents('https://www.google.com/search?q=moscow+russia&start=30'))));
https://secure.php.net/manual/en/function.htmlspecialchars.php
answered Nov 10 at 21:19
jiwopene
1688
1688
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243461%2ffile-get-contents-not-working-for-2-urls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is my answer ok?
– jiwopene
Nov 12 at 16:33