I can see the advantages of using the php define tag for example I could specify all my form fields on one page and link this to another .php page using an include tag and using the echo tag where I want the form field to be displayed for example. What I wanted to know is if this is the correct way to use the define tag.
<?php
// define.php
define("form_field_first_name", "<input type=text name=first_name size=20>");
define("form_field_last_name", "<input type=text name=last_name size=20>");
?>
<?
// show_form.php
include "define.php";
echo form_field_first_name; //
echo form_field_last_name; //
?>
php define tag
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
I don't think it's the intended way, but you can certainly do that if it's feasible in your application.
I think define() was intended to declare (aka. define) variables that you will never want to change throughout your whole app.
For example, I use define like this:
config.php
index.php
I think define() was intended to declare (aka. define) variables that you will never want to change throughout your whole app.
For example, I use define like this:
config.php
Code: Select all
<?php
define("USERNAME", "Jay");
define("PASSWORD", "xxx");
?>Code: Select all
<?php
include('config.php');
//Let the user login here
?>