1
I’m taking information from a site that generates content in format JSON and a question arose about using functions as parameters of other functions, this slows down the application? and if so, how to know?
Example:
$requestUrl = 'BlaBla.com';
$pageContent = json_decode(file_get_contents($requestUrl), true);
OR
$pageContent = file_get_contents($requestUrl);
$decodeContent = json_decode($pageContent, true);
Henry, I’m sorry, but... where is the function as a function parameter? Here
json_decode(file_get_contents($requestUrl), true);
?– Gustavo Cinque
passed file_get_contents() as parameter to json_decode
– Thiago
So... just for explanation, I wouldn’t answer your question, but it’s something useful, you’re not passing the function
file_get_contents()
forjson_decode()
, but yes is passing the function returnfile_get_contents()
as a function parameterjson_decode()
. Understands?– Gustavo Cinque
Then first the code block of the inner function will be processed, and then return will be sent as parameter to the outer function.
– Gustavo Cinque
Ah, got it, thanks for clarifying!
– Thiago