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

  • SEARCH
  • Home
  • 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 6182131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:08:57+00:00 2026-05-24T01:08:57+00:00

I am a beginner at programming. I am writing code using class inheritance. Here

  • 0

I am a beginner at programming. I am writing code using class inheritance. Here is the full code:

require_once('db.php');
class Activity extends DatabaseCall //this is in db.php
{ 

    public $name, $link, $activity_id;

    public function oneActivity( $name, $link, $activity_id )
    {
        $this->name = $name;
        $this->link = $link;
        $this->activity_id = $activity_id;
    } 
    private function activitiesArrays()
    {
        $this->sqlActivities(); //a protected function inherited from Parent
    }

    //Returns array of name + link + activity_id for random activity.
    //Works with function activitiesArrays(), which returns An Array of arrays of
    //names,links,and id's.
    // @param <array> $namesLinksIds_Arrays An Array of arrays of names, links,and  
    //id's.
    public function makesRandomActivity($namesLinksIds_Arrays)
    {
     $list($name, $linkk, $id) = $namesLinksIds_Arrays;
     $length = count($name);
     $rand = rand(0, $length-1);
        $n = $name[$rand];
        $l = $linkk[$rand];
        $i = $id[$rand];
     oneActivity($n, $l, $i);
    }

}

Everything in this code works if I comment out this code:

 public function makesRandomActivity($namesLinksIds_Arrays)
{
 $list($name, $linkk, $id) = $namesLinksIds_Arrays;
 $length = count($name);
 $rand = rand(0, $length-1);
    $n = $name[$rand];
    $l = $linkk[$rand];
    $i = $id[$rand];
 oneActivity($n, $l, $i);
}

Please help me figure out why this code does not work. Any help/suggestions/tips 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-24T01:08:58+00:00Added an answer on May 24, 2026 at 1:08 am

    The following line is incorrect :

    $list($name, $linkk, $id) = $namesLinksIds_Arrays;
    

    You want to use the list() language construct — so, remove the $ :

    list($name, $linkk, $id) = $namesLinksIds_Arrays;
    

    Using what you did, PHP intepreted the $list(...) as calling a function which name would have been contained inside the (unexisting) $link variable — about that, see Variable functions.

    Which basically means you were trying to assign $namesLinksIds_Arrays to a function invokation — which is why you were getting the following error message :

    Fatal error: Can't use function return value in write context 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iOS beginner here. I'm using the following code to save my facebook accessToken and
I am a beginner to programming when I start to code I just start
Throughout my days as a PHP Programmer and a beginner at C# programming I've
Level: Beginner I'm doing my first steps in Object Oriented programming. The code is
I'm a beginner in programming. I wrote a script to set DNS setting using
i am a beginner in iphone programming ,i found the following code on a
As a complete beginner with no programming experience, I am trying to find beautiful
I'm a complete beginner when it comes to programming. I'm taking a stab at
So, I am a total beginner in any kind of Windows related programming. I
Once again a very beginner-ish question, but here I go: I would like to

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.