Page 1 of 1
function inside function, will it work?
Posted: Fri Nov 03, 2006 2:12 am
by itsmani1
Code: Select all
<?PHP
function paxml($data)
{
function startElement($parser, $name, $attrs)
{
if($name == "ROW")
{
echo "Hay";
}
}
echo "Hay";
exit;
function endElement($parser, $name)
{
}
function characterData($parser, $name)
{
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parse($xml_parser, $data);
xml_parser_free($xml_parser);
}
?>
Its not working
Answer
Posted: Fri Nov 03, 2006 2:28 am
by gunman
You could insert function in function, but you should describe each function body separate. Something like this
Code: Select all
function f1(params)
{
body1
}
function f2(params)
{
body2
}
..
function fn(params)
{
bodyn
}
function whole(params)
{
f1(param);
f2(param);
..
fn(param);
}
Re: function inside function, will it work?
Posted: Fri Nov 03, 2006 2:39 am
by jmut
itsmani1 wrote:Code: Select all
<?PHP
function paxml($data)
{
function startElement($parser, $name, $attrs)
{
if($name == "ROW")
{
echo "Hay";
}
}
echo "Hay";
exit;
function endElement($parser, $name)
{
}
function characterData($parser, $name)
{
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parse($xml_parser, $data);
xml_parser_free($xml_parser);
}
?>
Its not working
this does not produce any error? what exactly is wrong?
Posted: Fri Nov 03, 2006 3:11 am
by itsmani1
tried this but still not working
Code: Select all
<?PHP
function startElement($parser, $name, $attrs)
{
if($name == "ROW")
{
echo "Hay";
}
}
function endElement($parser, $name)
{
}
function characterData($parser, $name)
{
}
function paxml($data)
{
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
echo "Hay";
exit;
xml_parse($xml_parser, $data);
xml_parser_free($xml_parser);
}
?>
I can't see any error, any suggestion how i can see errors
Posted: Fri Nov 03, 2006 3:20 am
by volka
Posted: Fri Nov 03, 2006 3:26 am
by jmut
itsmani1 wrote:tried this but still not working
Code: Select all
<?PHP
function startElement($parser, $name, $attrs)
{
if($name == "ROW")
{
echo "Hay";
}
}
function endElement($parser, $name)
{
}
function characterData($parser, $name)
{
}
function paxml($data)
{
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
echo "Hay";
exit;
xml_parse($xml_parser, $data);
xml_parser_free($xml_parser);
}
?>
I can't see any error, any suggestion how i can see errors
display_errors should be on. error_reporting (E_ALL)