PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm trying to make a page builder script so that I have a minimal amount of hard coded code. I have quickly run into problems though. I want one of my classes to do file_get_contents of a file that contains a basic beginning of each page.
Now just as an example, I want the defvar::styles to be parsed into what it's value is. I have this value , which I have set as an extends to the main class.
you'll need a tokenizing engine, a string replacement engine, or use a regex engine to 1) pull the variable name to use out, 2) replace that with the correct value.
so you'll need to come up with rules as to how the engine finds the variable name first. Then work out a system whereby you can give it the variables in some fashion to do replacement with.
Don't mean to be a pest, but could you elaborate on that for me...possibly show me an example or point me in the right direction of something that does? I checked php.net's info about the tokenizer, but I don't really get it.
a tokenizing engine basically is a loop that walks the string finding matching points. To speed the process, you can use strpos() and/or strstr()..
I personally prefer using regex, as it's more native to me There have been several threads (which are in the Regex forum here on DevNetwork) that talk about doing varialbe replacement....
Ok, one more thing to say, and if I'm wrong, just give me the ASCII finger and I'll go checkout the regex forum some more. However, my problem isn't that I can't find the variables, it's that once I do I can't parse them. I mean technically yeah I could, but I want to do it a certain way.
I can easily find where defvar::styles is, but the thing is, I want that to BE the value of defvar::styles, not just the string of it. Is there a way to do that? I just want to make sure you understand what I am wanting to do so that I am not looking in the wrong place.