Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8491403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:24:46+00:00 2026-06-10T22:24:46+00:00

I have no problem with creating php submenu class selected but when i try

  • 0

I have no problem with creating php submenu class selected but when i try to create this submenu inside submenu: I can’t get it work.

Problem: Defining echo inside echo returning syntax error because of quotes.

<ul class="sub_nav">
  <li <?php if ($page=='kurumsal-hakkimizda') {echo "class='selected'";} ?>>
    <a href="<?=BAZ_URL?>/tr/kurumsal-hakkimizda">Hakkımızda</a>
  </li>
  <li <?php if ($page=='kurumsal-ik') {echo "class='selected'";} ?>>
    <a href="<?=BAZ_URL?>/tr/kurumsal-ik">İnsan Kaynakları</a>
    <?php
      if ($page=='kurumsal-ik')
      { echo '
        <ul id="sub_sub_nav">

           <!-- !! PROBLEM STARTS HERE !! -->
           <li class="'if($page=='kurumsal-ik'){echo 'selected'}'">
           <!-- !! CANT USE ECHO INSIDE ECHO BEACUSE OF QUOTES !! -->

            <a href="'.BAZ_URL.'/tr/kurumsal-ik">İnsan Kaynakları Politikamız</a>
           </li>

           <li class="'if($page=='kurumsal-hedef'){echo 'selected'}'">
            <a href="'.BAZ_URL.'/tr/kurumsal-hedef">Kurumsal Hedef</a>
           </li>
        </ul>
     ';}
    ?>
  </li>
  <li <?php if ($page=='kurumsal-haberler') {echo "class='selected'";} ?>>
    <a href="<?=BAZ_URL?>/tr/kurumsal-haberler">Kurumsal Haberler</a>
  </li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:24:48+00:00Added an answer on June 10, 2026 at 10:24 pm

    Its already inside echo right? So do this:

    <li class="', ($page=='kurumsal-ik') ? 'selected' : '', '">
    

    It works for sure. It is called ternary operator! 🙂

    Note: Dot concatenation operator cannot be used here, because, the ternary operator acts as a function returning a value. Only comma , can be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an insert process in php but I have a problem in
Well, I have a problem (ok, no real problem, but I wanna try out
I have a problem making a select tag in php code dynamic. I'm creating
have a problem creating my new table in SqlLite3 I have created this migration
I am creating a PHP site and have ran into the following problem, i
I have following problem. I use this tutorial to creating a multiple file uploader:
I have no problem creating an AJAX call, but each url must at the
I have a problem creating my own librairie to send email. This is my
I'm very new with PHP and OOP techniques. So I have no problem creating
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.