Hello, I have a basic design question, in terms of what is "better"
programming.
I have a web site, and am using php pages as includes. some of the php
pages have php tags, and "echo" or "print" the php variables and html.
Like this:
<div id="body">
<?php include("phpincludes/server-nav.php"); ?>
</div>
the php page has code like this:
<div id="header">
<ul>
<li class="tab" <?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/index.php">Home</a>
</li>
<li class="tab" <?php if ($thisPage=="Introduction")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/intro.php">Introduction</a></li...
etc
is it better (or not) to not only echo divs, etc but to create
everything within php tags like this?
<?php echo ('<h2 class="decco" id="hdrTopic">Who We Are Not</h2>'); ?>
OR is this really the same thing, but looks different???
thanks again,
ewholz 5 1507
Better... No. Different... Yes.
Read this: http://www.faqts.com/knowledge_base/...l/aid/1/fid/40
better then me just restating what is there!
Matthew
eholz1 wrote:
Hello, I have a basic design question, in terms of what is "better"
programming.
I have a web site, and am using php pages as includes. some of the php
pages have php tags, and "echo" or "print" the php variables and html.
Like this:
<div id="body">
<?php include("phpincludes/server-nav.php"); ?>
</div>
the php page has code like this:
<div id="header">
<ul>
<li class="tab" <?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/index.php">Home</a>
</li>
<li class="tab" <?php if ($thisPage=="Introduction")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/intro.php">Introduction</a></li...
etc
is it better (or not) to not only echo divs, etc but to create
everything within php tags like this?
<?php echo ('<h2 class="decco" id="hdrTopic">Who We Are Not</h2>'); ?>
OR is this really the same thing, but looks different???
thanks again,
ewholz
For future programming the following, IMHO, works really well:
1.) Use "require_once()" instead of "include()". Some of my
applications get so harry that for saftey checks I will call a file
more then once, this protects re-establishing code. Also, require will
cause fatal error while include will only warn. You probably will want
to know for sure if a file made it ok.
2.) If your going to program in this way, use some of PHP's built in
short cuts:
Replace - <?php include("phpincludes/server-nav.php");?>
With - <?=require_once("phpincludes/server-nav.php")?>
Notice lack of "php" after "?" instead an "=" and no ";" at end. This
works and shrinks code ;)
Cheers,
Hackajar
eholz1 wrote:
Hello, I have a basic design question, in terms of what is "better"
programming.
I have a web site, and am using php pages as includes. some of the php
pages have php tags, and "echo" or "print" the php variables and html.
Like this:
<div id="body">
<?php include("phpincludes/server-nav.php"); ?>
</div>
the php page has code like this:
<div id="header">
<ul>
<li class="tab" <?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/index.php">Home</a>
</li>
<li class="tab" <?php if ($thisPage=="Introduction")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/intro.php">Introduction</a></li...
etc
is it better (or not) to not only echo divs, etc but to create
everything within php tags like this?
<?php echo ('<h2 class="decco" id="hdrTopic">Who We Are Not</h2>'); ?>
OR is this really the same thing, but looks different???
thanks again,
ewholz
>
Like this:
<div id="body">
<?php include("phpincludes/server-nav.php"); ?>
</div>
I would write this as
<?php
require_once(dirname(__FILE__) . '/phpincludes/server-nav.php');
?>
I use double quotes only for newlines and tabs. Also, PHP has a nasty
tendency to resolve relative paths with respect to the calling page, not
to the current page. So if this file was called from another directory,
the include file would be searched relative to _that_ directory first.
So I always use absolute paths.
Best regards
Try to check any source code from PEAR distribution. It's very clean.
And Óan be an example for imitation.
"""eholz1 ÐÉÓÁÌ(Á):
"""
Hello, I have a basic design question, in terms of what is "better"
programming.
I have a web site, and am using php pages as includes. some of the php
pages have php tags, and "echo" or "print" the php variables and html.
Like this:
<div id="body">
<?php include("phpincludes/server-nav.php"); ?>
</div>
the php page has code like this:
<div id="header">
<ul>
<li class="tab" <?php if ($thisPage=="Home")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/index.php">Home</a>
</li>
<li class="tab" <?php if ($thisPage=="Introduction")
echo " id=\"currentpage\""; ?>>
<a href="http://abf966/LBA/intro.php">Introduction</a></li...
etc
is it better (or not) to not only echo divs, etc but to create
everything within php tags like this?
<?php echo ('<h2 class="decco" id="hdrTopic">Who We Are Not</h2>'); ?>
OR is this really the same thing, but looks different???
thanks again,
ewholz
ha******@gmail.com wrote:
>>Hello, I have a basic design question, in terms of what is "better" programming.
I have a web site, and am using php pages as includes. some of the php pages have php tags, and "echo" or "print" the php variables and html.
Like this: <div id="body"> <?php include("phpincludes/server-nav.php"); ?> </div>
the php page has code like this: <div id="header"> <ul> <li class="tab" <?php if ($thisPage=="Home") echo " id=\"currentpage\""; ?>> <a href="http://abf966/LBA/index.php">Home</a> </li> <li class="tab" <?php if ($thisPage=="Introduction") echo " id=\"currentpage\""; ?>> <a href="http://abf966/LBA/intro.php">Introduction</a></li... etc
is it better (or not) to not only echo divs, etc but to create everything within php tags like this?
<?php echo ('<h2 class="decco" id="hdrTopic">Who We Are Not</h2>'); ?>
OR is this really the same thing, but looks different???
thanks again,
ewholz
(Top posting fixed)
For future programming the following, IMHO, works really well:
1.) Use "require_once()" instead of "include()". Some of my
applications get so harry that for saftey checks I will call a file
more then once, this protects re-establishing code. Also, require will
cause fatal error while include will only warn. You probably will want
to know for sure if a file made it ok.
2.) If your going to program in this way, use some of PHP's built in
short cuts:
Replace - <?php include("phpincludes/server-nav.php");?>
With - <?=require_once("phpincludes/server-nav.php")?>
Notice lack of "php" after "?" instead an "=" and no ";" at end. This
works and shrinks code ;)
And fails on any host which has short_open_tags turned off, which is
more and more common. Much better to use <?php.
Cheers,
Hackajar
eholz1 wrote:
P.S. Please don't top post.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: byrocat |
last post by:
I'm chasing after a documetn that was available on one of the Microsoft
websites that was titled somethign like "MS SQL Server Best Practices"
and detailed a nyumber of best practices about...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: john doe |
last post by:
A quick question, about so-called 'best practices', I'm interested in
which of A/B of the two examples people would choose, and why.
public enum MyEnum
{
Option1 = 0,
Option2 = 1,
Option3 =...
|
by: |
last post by:
Hi can someone send or point me to Any nice Material on .NET Best Practices
-regards
|
by: Amelyan |
last post by:
Could anyone recommend a book (or a web site) that defines best practices in
ASP.NET application development?
E.g.
1) Precede your control id's with type of control btnSubmit, txtName, etc.
2)...
|
by: Luis Esteban Valencia |
last post by:
Hello. Can somebody recomend me books of design patterns in c# and best
practices too.
|
by: jojobar |
last post by:
Hello,
I am trying to use vs.net 2005 to migrate a project originally in vs.net
2003. I started with creation of a "web site", and then created folders for
each component of the site.
I read...
|
by: Louis Aslett |
last post by:
I hope this is the correct newsgroup for this query (if not please
give me a pointer to where is best):
I understand the theory of normalisation etc and am trying to follow
best practices in the...
|
by: Ren |
last post by:
Hi All,
I'm still rather new at vb.net and would like to know the proper way to access
private varibables in a class. Do I access the variable directly or do I use
the public property?
...
|
by: John Dalberg |
last post by:
I am looking for an ASP.NET application on CodePlex which exemplifies best
practices for the following:
- Use of interfaces
- Seperation of the UI, business and data tiers
- Data Tier that uses...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |