Answer the question
In order to leave comments, you need to log in
(RedBeanPHP) Why am I getting NULL?
Output functions:
function showService()
{
$services = R::load( 'services', 4 );
return $services;
}
function index()
{
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if( $link == 'http://'.$_SERVER['HTTP_HOST'].'/service.php' )
{
showService();
//createService();
}else{}
}
echo $services->title;
Answer the question
In order to leave comments, you need to log in
Who teaches you all red bin, without letting you read the PHP primer?
First we read about the scope
Then we start such an interesting process as "thinking":
we look at the code
and think why on earth we will have the $services variable here after calling this function. Answer: none.
After that, we read about returning values from functions and again think about how we can get the value that the function returns to us into the variable. so that later we can finally use this variable.
Hint: You can see an example in the third line of the code in the question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question