RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 760 | Replies: 2 | Thread Tools  Display Modes
Reply
Join Date: Jan 2008
Posts: 2
Reputation: kudzugazette is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kudzugazette kudzugazette is offline Offline
Newbie Poster

Simple Question about PHP

  #1  
Jan 27th, 2008
I have been using PHP sparsely on my website for some time now, but I would like to become more efficient and therefore have a couple questions. They will stream in slowly, bu for right now...

Currently I use the <?php tag many times on a page. Is there a way to get rid of it? Example:

<?php
require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>The Kudzu Gazette</title>

<?php
include("./header_home.php");
?>
<!-- Content Here -->


<?php
include("cutenews/show_news.php");
?>


<!-- End Content -->
<?php
include("./footer.php");
?>

Thanks. Sorry for my newbieness
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 57
Reputation: Walkere is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
Walkere Walkere is offline Offline
Junior Poster in Training

Solution Re: Simple Question about PHP

  #2  
Jan 27th, 2008
Originally Posted by kudzugazette View Post
I have been using PHP sparsely on my website for some time now, but I would like to become more efficient and therefore have a couple questions. They will stream in slowly, bu for right now...

Currently I use the <?php tag many times on a page. Is there a way to get rid of it?

Sometimes you can cut down on it. Other times it's necessary to open and close php tags a lot.

In your case, you can cut down significantly on the opening/closing brackets. In between the includes, you don't use any regular html. So you can cut them all down into one php segment like so...

  1. <?php
  2. require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs
  3. ?>
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5. <head>
  6. <title>The Kudzu Gazette</title>
  7.  
  8. <?php
  9. include("./header_home.php");
  10.  
  11. include("cutenews/show_news.php");
  12.  
  13. include("./footer.php");
  14. ?>

And if you wanted to make it all one big php block, you could do this...

  1. <?php
  2. require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs
  3.  
  4. echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
  5. echo '<head>';
  6. echo '<title>The Kudzu Gazette</title>';
  7.  
  8. include("./header_home.php");
  9.  
  10. include("cutenews/show_news.php");
  11.  
  12. include("./footer.php");
  13. ?>

Good luck,
- Walkere
Reply With Quote  
Join Date: Jan 2008
Posts: 2
Reputation: kudzugazette is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kudzugazette kudzugazette is offline Offline
Newbie Poster

Re: Simple Question about PHP

  #3  
Jan 28th, 2008
Awesome. thanks.
-Will

Originally Posted by Walkere View Post
Sometimes you can cut down on it. Other times it's necessary to open and close php tags a lot.

In your case, you can cut down significantly on the opening/closing brackets. In between the includes, you don't use any regular html. So you can cut them all down into one php segment like so...

  1. <?php
  2. require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs
  3. ?>
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5. <head>
  6. <title>The Kudzu Gazette</title>
  7.  
  8. <?php
  9. include("./header_home.php");
  10.  
  11. include("cutenews/show_news.php");
  12.  
  13. include("./footer.php");
  14. ?>

And if you wanted to make it all one big php block, you could do this...

  1. <?php
  2. require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs
  3.  
  4. echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
  5. echo '<head>';
  6. echo '<title>The Kudzu Gazette</title>';
  7.  
  8. include("./header_home.php");
  9.  
  10. include("cutenews/show_news.php");
  11.  
  12. include("./footer.php");
  13. ?>

Good luck,
- Walkere
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:23 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC