Hi,
I'm a bit new to PHP and the only command I've been using a lot lately is the include command.
Which way should I write my include statement (see below)? Is there a preferred way? Are there any explicit cons/pros with each?
<?php include "header.htm">
<?include "header.htm"; ?>
BTW: I'm using an .htm extension for the header file, as the php extension gave me problems (I'm also using it as a plain frame in another page).
Please let me know. I'm currently using the latter option, and someone accussed my code of creating "errors".
Question reg. PHP include code, recommended formating?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
By using:
you are relying on short tags (<? ?>) being enabled on the server (they are often disabled). To make your code more portable use:
as long tags (<?php ?>) are always enabled.
Mac
Code: Select all
<?include "header.htm"; ?>Code: Select all
<?php include 'header.htm'; ?>Mac