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!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
Hi I am a total newbie and am trying to learn a bit of php . Please help!!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
In my opinion, Wordpress should not be used as a coding standard to try & strive for. They've set up their template engine so as to be as simple as possible for designers to interpret. It is not a pillar of how things should be done.
Why do you want to change what you've got? For most cases, your code looks fine to me.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
So you want to (wisely) separate program logic from display logic?
Have you looked into template engines? I know this may be going beyond the scope of your initial question. However, if your goal is to properly build a script that is easy to update & theme in the future, the question is bigger than you initially posted.
To answer your initial question, you'd have to declare the result set global so you could access it between all your functions. I don't know, but I'd guess Wordpress loads all it's data first & stores it all in PHP variables, then those little functions are used to access those variables.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
pickle wrote:To answer your initial question, you'd have to declare the result set global so you could access it between all your functions. I don't know, but I'd guess Wordpress loads all it's data first & stores it all in PHP variables, then those little functions are used to access those variables.
Which slows down your application. It gives it more overhead (Making functions that access global variables that hold all of the data), I'm sure everyone here has seem many Wordpress sites down.
Using a template engine will definitely slow down the process. That said, any code organization that causes you to use anything other than a single file with full procedural code will slow down the process. However, one has to decide if a particular way of organizing code is worth the trade off in performance. Doing things like making class files is almost certainly worth the trouble. Usually, using a template engine is worth the trouble as well.
I have no idea how much of a performance hit Wordpress takes because of the way they chose to do their template engine. It's really tough to say because there's really no before & after testing available.
If you are looking at using a template engine, Smarty is the most popular. There is another library out that I and a couple other people really like called Template Lite. It's based off Smarty & is actually just a port of Smarty to a leaner, less process-intensive version.