1

I have the following example:

I have an array of values in config\resources.php - eg.:

<?php
    define('resrc', array(
        'logo' => 'src/images/logo.png',
        'bscss' => 'src/bootstrap.css',
        'bsthcss' => 'src/bootstrap-theme.css',
        'bsjs' => 'src/js/bootstrap.js',
        'chset' => 'utf-8',
        'jquery' => '/src/jquery/jquery_1.12.4_min.js',
        )
    );
?>

Now in the structure\head.php I have something like this:

<?php
require('config/resources.php');
class Head {
    public static $head;
    public static function renderHeadTag() {

        $head = "<head>";
        $head .= "<meta charset=".$resrc['chset'].">";
        $head .= "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">";
        $head .= "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";

        $head .= "</head>";

        return $head;
    }
}
?>

but I still can't get the value of the array. It is quite a while since i were doing something like this. Can anybody give a hint?

1 Answer 1

3

you are using a constants array

calling constants must not prefixed with dollar sign

this line :

$head .= "<meta charset=".$resrc['chset'].">";

should be as follows :

$head .= "<meta charset=".resrc['chset'].">";

P.S. constants following some naming convention , it's better (not must have) to name your constants in capital letters, RESRC for example

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot :) looks like it was a long time :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.