Ik hebmet php en html een simpel template ding in elkaar geflansd.
Het gene wat ik mij afvraag is hoe je variabelen kunt vervangen door php code. Dit werkt op het moment dus niet.
Dit is het template bestand:
Dit is het bestand dat de template verwerkt:
Ik denk dat er ergens een syntaxprobleempje zit...
btw dit is de output source:
Dank u hartelijk!
Het gene wat ik mij afvraag is hoe je variabelen kunt vervangen door php code. Dit werkt op het moment dus niet.
Dit is het template bestand:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
| <?php $template=" <html> <head> <title>{title}</title> {head} </head> <body bgcolor={bodycolor}> {body} </body> " ; ?> |
Dit is het bestand dat de template verwerkt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
| <?php include("tpl.php"); $bodycolor="red"; $title="Test...ikel"; $head="<?php function blaat(){echo'blaat';} ?>"; $body="<?php blaat(); ?>"; $template = str_replace("<?title}", $title, $template); $template = str_replace("{bodycolor}", $bodycolor, $template); $template = str_replace("{body}", $body, $template); $template = str_replace("{head}", $head, $template); echo $template; ?> |
Ik denk dat er ergens een syntaxprobleempje zit...
btw dit is de output source:
code:
1
2
3
4
5
6
7
8
| <html> <head> <title>Test...ikel</title> <?php function blaat(){echo'blaat';} ?> </head> <body bgcolor=red> <?php blaat(); ?> </body> |
Dank u hartelijk!