Welcome Guest, Not a member yet? Register   Sign In
Controllers name
#1

[eluser]Unknown[/eluser]
Hi, i am new italian user.
CI is very good.

I have a problem.
I would want to call my controller 'my-test' but this create this error

Parse error: syntax error, unexpected '-', expecting '{' in D:\wwwroot\codeigniter\system\application\controllers\my-test.php on line 3

Why i cannot use the character '-' on my controllers?

Thanks you
#2

[eluser]gtech[/eluser]
don't think i have ever used a '-' in a function name. Can you not just use a '_' instead. I guess php might be expecting the '-' to mean minus and thats why you get the parse error.
#3

[eluser]Unknown[/eluser]
[quote author="gtech" date="1194986122"]don't think i have ever used a '-' in a function name. Can you not just use a '_' instead. I guess php might be expecting the '-' to mean minus and thats why you get the parse error.[/quote]

opps... this is a PHP error and not a CI error...

you excuse to me
#4

[eluser]xwero[/eluser]
Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*. php.net

I never used it either but if you see it through an SEO view it would make sense to use a hyphen between words. But you can solve it using routes.




Theme © iAndrew 2016 - Forum software by © MyBB