Wordpress trick

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!

Moderator: General Moderators

Post Reply
orvacko
Forum Newbie
Posts: 2
Joined: Thu Feb 10, 2011 9:03 am

Wordpress trick

Post by orvacko »

Hi all.
I saw in wordpress index.php this trick :

Sorce code:

Code: Select all

<title>{TITLE}</title>
HTML out:

Code: Select all

Testing blog
- do you know how they did this ? because zhere is no <?php echo .. etc ;)
THX
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Wordpress trick

Post by John Cartwright »

They use a template engine to parse for "tokens", and replace it with their value.

I.e., a simple example would be

Code: Select all

$your_template = 'hello {name}';

echo str_replace('{name}', 'John Cartwright', $your_template);
orvacko
Forum Newbie
Posts: 2
Joined: Thu Feb 10, 2011 9:03 am

Re: Wordpress trick

Post by orvacko »

THX man ;) I know that, it only looks easy, but that background of its .. omg
Post Reply