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

Recommended Answers

All 2 Replies

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...

<?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");

include("cutenews/show_news.php");

include("./footer.php");
?>

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

<?php
require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs

echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
echo '<head>';
echo '<title>The Kudzu Gazette</title>';

include("./header_home.php");

include("cutenews/show_news.php");

include("./footer.php");
?>

Good luck,
- Walkere

Awesome. thanks.
-Will

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...

<?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");

include("cutenews/show_news.php");

include("./footer.php");
?>

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

<?php
require('./cutenews/captcha/php-captcha.inc.php'); //Change the path to your needs

echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
echo '<head>';
echo '<title>The Kudzu Gazette</title>';

include("./header_home.php");

include("cutenews/show_news.php");

include("./footer.php");
?>

Good luck,
- Walkere

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.