Learn, Share, Build

October 08, 2017, at 01:48 AM

I've looked all over and even watched a simple Youtube video on how to create dynamic titles for each page cause you don't want each page having the same title, right? Right.

So in my header.php file I've created a variable between the head tags like so:

<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
<title><?php echo ['$pagetitle']; ?></title>

And of course in one of my index.php files I've defined the variable like so:

<?php $pagetitle = 'some-page-title'; ?>

It can't get any simpler than this by creating a variable and defining what that variable will be called. But it seems this isn't flying.

I'm using PHP5.6 in XAMPP for testing purposes, and I also use Netbeans which isn't correcting me for the way I created the PHP code; and I'm getting a "undefined variable" page_title and an ARRAY to string conversion in the header.php file. I have defined the variable so why am I getting an array error thrown at me? There must be something I'm missing cause I've looked closely at everything.

Thanks for taking the time to view and answer!

Answer 1

I did exactly that for my projects. index.phtml

            $title = "Some title";
        <!-- whatever code ... -->


    echo "<title>$title</title>\n";
    # something else if needed...

Works just fine.

Rent Charter Buses Company
Learn, Share, Build

Learn, Share, Build

I am looking a regular expression that contains two logic: 1Does not contain any white space 2

Learn, Share, Build

Learn, Share, Build

I would like to learn how to excute shell commands right from mysqlMy MYSQL version is 5

Learn, Share, Build

Learn, Share, Build

I am at the stage of the OAuth flow where I get the OAuth verifier and have to use it to get the permanent token, however I encounter the error "Invalid oauth_verifier parameter"

Learn, Share, Build

Learn, Share, Build

I would like to catch somehow the laravel error, warning messageI don't want to disable them from the config/app