Read php code on string without eval function

Solution:1

Why reinvent the weel? Most people use frameworks for these kind of things. Look into http://phalconphp.com/ http://docs.phalconphp.com/en/latest/reference/volt.html