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

  • Home
  • SEARCH
  • 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 8542907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:10:47+00:00 2026-06-11T12:10:47+00:00

So lets say i have a php file that contains $title=Website | Categories; And

  • 0

So lets say i have a php file that contains

$title="Website | Categories";

And my header.inc file includes <title><?=$title?></title> which will output the title name.

But lets say i also have a variable on my php page called 'cat_name'

How can i add ‘cat_name’ into $title="Website | Categories"; Would it be like
$title="Website | Categories 'cat_name'";

  • 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-11T12:10:49+00:00Added an answer on June 11, 2026 at 12:10 pm

    These will work:

    • $title = "Website | Categories " . $cat_name;
    • $title = "Website | Categories $cat_name";

    This will not work:

    • $title = 'Website | Categories $cat_name';

    If a string is in double-quotes it will parse any variables inside of it. However, if the string is in single quotes it will not.

    If you want to get a little fancier there are various ways to append the category name with another vertical pipe, like Website | Categories | My Category.

    The simplest is probably using the ternary operator to detect if $cat_name is set and append text to the $title string.

    $title = "Website | Categories";
    $title .= (isset ($cat_name)) ? " | $cat_name" : "";
    

    You could also create an array and add each element of your navigation to it (Website, Category, cat_name, sub_cat, sub_sub_cat, …) then use an implode statement to turn it into a string.

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

Sidebar

Related Questions

I have a function language($tag) that requires a file lang.php which contains an array
I have a php file that show the friends requests, lets say there are
I have a web server which returns an XML file. Lets say http://www.foo.bar/foo.php?wantXML=1 How
lets say i have two pages links.html & contents.php ... first page contains only
Lets say that i have 2 pages: index.php and service.php index.php sends an http-post
Let's say I have a main folder in my website named test which contains
Hello I have a jQuery function that will send to a php file some
Lets say I have an old application which will try to load an external
I have a php file lets say test.php?x=1 with .htaccess i can rewrite the
I have a class that has a function, lets say class.php: class fun {

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.