/    Sign up×
Community /Pin to ProfileBookmark

PHP Syntax Question

I’m having issues with the else command on this and was wondering what the correct syntax is:

[code=php]
if ($_SERVER[‘SCRIPT_FILENAME’] == “/var/www/vhosts/mydomain.com/httpdocs/index.php”){
echo “<div class=’home-nav’>
<ul class=’nav’>
<li><a href=’index.php’ title=’Home’ class=’selected’><span>Home</span></a></li>
<li><a href=’#’ title=’Renew’><span>Renew</span></a></li>
<li><a href=’#’ title=’Status’><span>Status</span></a></li>
<li><a href=’about.php’ title=’About Us’><span>About Us</span></a></li>
<li><a href=’#’ title=’Support’><span>Support</span></a></li>
<li><a href=’contact.php’ title=’Contact Us’><span>Contact Us</span></a></li>
</ul>
</div>;”
else
echo “<div class=’inner-nav’>
<ul class=’inner-nav’>
<li><a href=’index.php’ title=’Home’ class=’selected’><span>Home</span></a></li>
<li><a href=’#’ title=’Renew’><span>Renew</span></a></li>
<li><a href=’#’ title=’Status’><span>Status</span></a></li>
<li><a href=’about.php’ title=’About Us’><span>About Us</span></a></li>
<li><a href=’#’ title=’Support’><span>Support</span></a></li>
<li><a href=’contact.php’ title=’Contact Us’><span>Contact Us</span></a></li>
</ul>
</div>”;

}?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 17.2010 — You need a closing brace before the [b]else[/b] and an opening brace after it.
[code=php]
if($condtion) {
// commands
}
else {
// commands
}
[/code]
Copy linkTweet thisAlerts:
@tracknutNov 17.2010 — And this:
<i>
</i> &lt;/div&gt;;"


should be this:
<i>
</i> &lt;/div&gt;";
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...