Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Syntax error in i18n url function to add to AppHelper #13

Closed
ghost opened this issue Mar 28, 2012 · 2 comments
Closed

Syntax error in i18n url function to add to AppHelper #13

ghost opened this issue Mar 28, 2012 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 28, 2012

This function to add to AppHelper doesn't work. It returns an synatx error:
"Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ')'"

    public function url($url = null, $full = false) {
        if (empty(is_array($url) && !array_key_exists('lang', $url)) {
            $url['lang'] = Configure::read('Config.language');
        }
        return parent::url($url, $full);
    }

The problem is the "&&" in the if clause...
For info, I'm using Cake 1.3.14 and PHP 5.3.8

@ghost
Copy link
Author

ghost commented Mar 28, 2012

When I use this version, it seems to work, the lang parameter is added, but I'm not sure it is the correct way...

    if (is_array($url) && !array_key_exists('lang', $url)) {
        $url['lang'] = Configure::read('Config.language');
    }
    return parent::url($url, $full);

@ghost
Copy link
Author

ghost commented Mar 28, 2012

I'm sorry, but your correction doesn't work!

Fatal error: Can't use function return value in write context

the problem is the test "empty(is_array($url))"

@steinkel steinkel reopened this Jul 23, 2012
@ghost ghost assigned steinkel Jul 23, 2012
steinkel added a commit that referenced this issue Jul 23, 2012
Repository owner unassigned steinkel Mar 4, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants