Problems with echo

I am having a problem getting results using html, echo works, but it ignores the html and put the text at the top of the page.

Here is the echo that i am using

echo 'Directory '.$dir.' is there and writeable, excellent.<br/>';

Here is what it displays, which is what i want but not where i want it.

Directory cache/corps is there and writeable, excellent. Directory cache/data is there and writeable, excellent. Directory cache/map is there and writeable, excellent. Directory cache/portraits is there and writeable, excellent. Directory cache/templates_c is there and writeable, excellent.

And when i use this html it doesnt give me the same output

html .= 'Directory '.$dir.' is there and writeable, excellent.<br/>';

Just for reference ere is the section of code im trying to work with.

[code]function checkdir($dir)
{
if (is_writeable($dir))
{
echo ‘Directory ‘.$dir.’ is there and writeable, excellent.
’;
}
else
{
$html .= ‘I cannot write into ‘.$dir.’, you need to fix that for me before you can continue.
’;
$html .= ‘Please issue a “chmod 777 ‘.$dir.’” on the commandline inside of this directory
’;
global $stoppage;
$stoppage = true;
}
}

if (is_writeable(‘cache’))
{
$html .= ‘Cache directory is writeable, testing for subdirs now:
’;
checkdir(‘cache/corps’);
checkdir(‘cache/data’);
checkdir(‘cache/map’);
checkdir(‘cache/portraits’);
checkdir(‘cache/templates_c’);
}[/code]

Not sure what you’re trying to achieve, but lemme start by saying that the line breaks (which are essentially HTML) seem to be output correctly. You can verify this by viewing the source of the output.

Second, you’re using a function, in which you don’t initialize the variable $html. You’ll have to give it a value (which can be an empty string) before you can append it (by using .= ). Also, you’re appending the $html variable outside the function as well. Please realize that this is a DIFFERENT variable than the one used in the function.

add return $var to your function and then just echo the function

Sponsor our Newsletter | Privacy Policy | Terms of Service