I have following problem. I have file variable.php with declared variable:
<?php
$animal = "cat";
?>
And file b.php, where I want to use this variable in a function
<?php
include_once 'a.php';
function section()
{
$html = "<b>" . $animal "</b>";
return $html;
}
?>
and file c.php where I’m using my function section()
<?php
require_once 'b.php';
echo section();
?>
I have an error message, that variable $animal does not exist in file b.php. Why and what can I do here?
Best regards,
Dagna
send
$animal;to the function: