I would like to do something like this:
<my_tag_name>
text..
any_text
</my_tag_name>
but the problem appears what if the user puts the content like this:
<my_tag_name>
text..
any_text
</my_tag_name>
</my_tag_name>
So I replaced < with <'
function content($string, $tagname)
{
$pattern = "/<$tagname>([\w\W]*?)<\/$tagname>/";
$preg_match($pattern, $string, $matches);
return str_replace("<'", "<", $matches[1]);
}
function replace($string)
{
return str_replace("<", "<'", $string);
}
The goal is to have custom tags and any kind of text as a content. Is this correct approach? I tried it and it works. But then again I remembered the same principle is in html but there you can't put let's say < div> my content < div> < /div>.
I also wanted to have like this:
tag: reserved_64_characters
tag2: reserved_64_characters
How are these things implemented in XML? Is there also some escaping/replacing. I would like to do that any content can be inserted I mean any characters(also < tag_name >..).
On http://www.w3schools.com/xml/xml_cdata.asp
Notes on CDATA sections:
A CDATA section cannot contain the string "]]>"