Adding a small String variable to an array causes a syntax error?

I am trying to add a dash -and a specific line $pageurleimmediately after {target}, since the URL in href (below the code) expands naturally with a dash and the contents of the variable $ pageurle

See the existing code snippet in which I would like to enter a dash and a variable right after href:

// html for breadcrumbs
var $breadcrumb_templates = array(
    'separator' => '→',
    'link'      => '<a href="{target}">{name}</a>',
    'wrapper'   => '<div class="breadcrumbs">{items}</div>', 
);

Now, when I add a dash and $ pageurle, dreamweaver says that I am doing something wrong and demonstrates the anus. I must be doing something stupid here ... but what? Your ideas / code / improvements / possible immersions in this issue are very appreciated by me.

enter image description here

+3
source share
2 answers

, "var" PHP 4 PHP 5.

-, - (, "." ()).

:

class MyClass
{
    private $breadcrumb_templates;

    public function __construct()
    {
        $this->breadcrumb_templates = array(
            'separator' => '&rarr;',
            'link'      => '<a href="{target}">{name}</a>',
            'wrapper'   => '<div class="breadcrumbs">{items}</div>', 
        );
    }
}
-1

, (var ), .

- .

.

Edit

class MyClass
{
    public $breadcrumb_templates = array(
        'separator' => '&rarr;',
        'link'      => '<a href="{target}">{name}</a>',
        'wrapper'   => '<div class="breadcrumbs">{items}</div>',         
    );

    public function __construct($pageurle = null)
    {
        if (null !== $pageurle) {
            $this->breadcrumb_templates['link'] =
                sprintf('<a href="{target}-%s">{name}</a>', $pageurle);
        }
    }
}
+3

All Articles