Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:35:50+00:00 2026-05-26T21:35:50+00:00

Consider the following function declaration for checking current language on a bilingual website: function

  • 0

Consider the following function declaration for checking current language on a bilingual website:

function checkNewsLanguage(){
    $requiredURL = $_SERVER['REQUEST_URI'];
    $myLanguage = explode('?lang=',$requiredURL);
    if($myLanguage=='en')
        return false;
    else return true;
}

Then I get some XML objects in the required language using functions like:

function item1('checkNewsLanguage')
    if(checkNewsLanguage()){
        $urlD = "someurl1";
        $xmlD = simplexml_load_file(cacheFetch($urlD,'cachedfeed1.xml',3600));
        $itemD = '';
        if($xmlD === FALSE)
            {$itemD = '';}
        else
            {$itemD = $xmlD->channel->item;}
    }
    else {
        $urlD = "someurl2";
        $xmlD = simplexml_load_file(cacheFetch($urlD,'cachedfeed2.xml',3600));
        $itemD = '';
        if($xmlD === FALSE)
            {$itemD = '';}
        else
            {$itemD = $xmlD->channel->item;}
    }
    return $itemD;
    }
function item2('checkNewsLanguage')
//Analogic procedure

I get "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '&' or T_VARIABLE ". As you see the function calls in item1() and item2() are not correct. Any code help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:35:51+00:00Added an answer on May 26, 2026 at 9:35 pm

    Your function arguments need to be a variable, not just a string (as the error suggests). Your functions should be defined like:

    function item1($variableHere) and not function item2('string here').

    As I look at your code again, it seems what you are trying to do is call a certain function based on the parameter of item1() and item2() (so if you pass item1(foo) you want to call the foo() function.

    Try:

    function item1($function)
    {
        if ($function()) 
        { 
            ...
        }
    }
    

    and similar for item2(). This way you can call item1('checkNewsLanguage') and that is the function it will call inside of the body.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have faced the following interview question. Consider this function declaration: void quiz(int i)
Consider the following function: void f(const char* str); Suppose I want to generate a
Consider the following base code: (function($) { $.fn.myPlugin = function(settings) { return this.each(function() {
Let's consider the following scenario: a function which can generate code colors from white
Consider the following snippet: $(document).bind('mousemove', function(e) { $('#someDiv').css({left: e.pageX+'px', top: e.pageY+'px'}); }); This should
Howdy. Consider the following: SQL> DECLARE 2 b1 BOOLEAN; 3 b2 BOOLEAN; 4 FUNCTION
Consider the following declaration of a generic utility class in Delphi 2010: TEnumerableUtils =
Consider the following function: public function foo(bar1:int, bar2:uint, bar3:String, bar4:Boolean):void{} What I want is
Consider the following function template: template<typename T> void Foo(T) { // ... } Pass-by-value
Consider the following Java function: public void foo(Class<? extends Exception> cl, List<? extends Exception>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.