saltedm8 Posted September 5, 2009 Share Posted September 5, 2009 I am just learning php but I have messed with phpbb in the past and also one or 2 cms systems, .. I have seen this << my_command >> and also this { my_command } being used to call a script into a template so for example if I typed in { CALL_MENU } then the script will get the menu script I was wondering if anyone has any idea how this is done, Im not doing it for any project but it has just got me curious.. if you could give me a simple understandable explanation, I would love to see it thank you Link to comment https://forums.phpfreaks.com/topic/173222-call-a-script-using-a-single-command/ Share on other sites More sharing options...
Mardoxx Posted September 5, 2009 Share Posted September 5, 2009 no, look at the php code Link to comment https://forums.phpfreaks.com/topic/173222-call-a-script-using-a-single-command/#findComment-913125 Share on other sites More sharing options...
ignace Posted September 5, 2009 Share Posted September 5, 2009 They use something like preg_match Once they have all matches they look if it is one of the possible resources (function, ..). If it is they replace it with the output of the resource. $matches = array(); if (preg_match('/{([A-Z-_]+)}/i', $str, $matches)) { foreach ($matches as $match) { $functionName = strtolower(trim($match, '{}')); if (function_exists($functionName)) { $output = call_user_func($functionName); $str = str_replace($match, $output, $str); } } } Link to comment https://forums.phpfreaks.com/topic/173222-call-a-script-using-a-single-command/#findComment-913133 Share on other sites More sharing options...
saltedm8 Posted September 5, 2009 Author Share Posted September 5, 2009 thanks for that, I might try to give it a go lol... although I probebly have a long way to go before I completly understand what it going on there lol Link to comment https://forums.phpfreaks.com/topic/173222-call-a-script-using-a-single-command/#findComment-913136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.