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

This is a topic that, as a beginner to PHP and programming, sort of
I'm a beginner to C programming. I'm trying to learning how to code a
I'm just starting to get into jquery/javascript programming so this may be a beginner
I am a beginner in programming. I have a large piece of code. I
Im still a beginner in C programming and I need a little help writing
I'm currently doing a project for a Beginner C programming class where i'm supposed
In a beginner's programming book (free licence) there was the following code, dynamically creating
This is NOT a homework. I'm a beginner in programming, and also this is
I'm a beginner in programming and I often see many programs using the prefix
I am a beginner to programming when I start to code I just start

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.