Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts

    PHP incude_once Question

    I am not to sure what best way to go is about this

    at the moment I include header and footer on the top and bottom i.e. footer for bottom and header for top.

    In my index.php file I would like to find out if it is possible to define or include if file has .tpl on end of it.

    That way easy for me to edit then

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yes, but if its unparsed PHP code, than the variables will come as literal text.
    You can use eval, but I wouldn't since its very slow, and also the only function in PHP that *everysingletime* I use it never works the first time. I haven't a clue why I'm so bad with it.
    If its just text, then that's not a problem.
    Why does the extension matter on this? Another alternative is to keep the .tpl and add a handler to the webserver to parse the .tpl as PHP. That will also work.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    118
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Ok with give it a go trying many things out at the moment want to learn my self but my pay my programmer to do it.

    Just starting to learn php and tpl now

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    Quote Originally Posted by Fou-Lu View Post
    Yes, but if its unparsed PHP code, than the variables will come as literal text..
    if you include it locally ... /home/path/header.blah , then the php will parse, but not if you use url http://etc/header.blah unless as you say .blah is set to parse as php

    ++feelingyourpain with eval
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts

    Your right it does! Learn something new every day. I guess that makes sense though since the primary script's just assembling the text from the others.

    Although there is a downside; if its not set up to parse as PHP, it can be inspected as plain text.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    Quote Originally Posted by Fou-Lu View Post

    Although there is a downside; if its not set up to parse as PHP, it can be inspected as plain text.
    absolutely, good point !
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •