Can I do this

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
benandrewsmx
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Aug 11, 2017 3:35 pm

Fri Aug 11, 2017 3:44 pm

Hi everyone,

im very new to php and wanted to start to learn it a little more then i already do. im creating a theme to use on a website, but im a bit lazy so wanted to use templates for the header and footer for example.

But i want to be able to change the site title, meta data that sort of thing for each page with out having to copy and pasts the header. if you know what i mean.

so my solution to this was to create the variables at the top of the page so for ex:

<?php site-title = '''what ever the title is'"?>

then calling the header fill like so

<?php include_once "path to file" ?>

and in there it would have

<title><?php echo $site-title ?></title>

so my question is, is this an acceptable way of doing it... i know it works but is it ok..

thanks Ben

User avatar
hyper
php-forum Active User
php-forum Active User
Posts: 412
Joined: Mon Feb 22, 2016 5:52 pm

Sat Aug 12, 2017 3:33 am

Yes, that's exactly what you're supposed to do; it helps to maintain consistency and ease of editing.

benandrewsmx
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Aug 11, 2017 3:35 pm

Sun Aug 13, 2017 7:21 am

Thanks for responding... and clearing that up for me

ben

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests