Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Director::addRules, undefined variable Action


Go to End


3 Posts   1003 Views

Avatar
esakrielaart

Community Member, 59 Posts

12 April 2012 at 11:20pm

Hi all,

strange problem, when I use Director::addRules(50, array( ASSETS_DIR."/$Action" => "SomeActionController")); I get the notice: "Variable Action not defined.". However, I don't see how other _config.php files do define this 'variable'. Something I'm missing?

Regards,
Maurice

Avatar
(deleted)

Community Member, 473 Posts

13 April 2012 at 8:36am

This is because you're using double quotes rather than single quotes. With double quotes, PHP tries variable substitution on the string. With single quotes, it leaves the string as is. (see http://nz.php.net/manual/en/language.types.string.php#language.types.string.syntax.single).

Using Director::addRules(50, array( ASSETS_DIR.'/$Action' => "SomeActionController")); will work fine.

Avatar
esakrielaart

Community Member, 59 Posts

13 April 2012 at 9:33pm

Very well, and also thanks for the link to the proper documentation from PHP! This indeed solved the problem for me.