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 6476737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:51:43+00:00 2026-05-25T06:51:43+00:00

Disclaimer: I’m new to object-oriented PHP and I’m generally terrible at the language. So

  • 0

Disclaimer: I’m new to object-oriented PHP and I’m generally terrible at the language.

So I’ve got a class called “Page” in a file (class_lib.php) and I’ve created this variable and written a while/for loop that processes it when its set:

public $extra= "";
if (isset($this->extra)) {
echo "<table id=\"tab\">";
while (list($counter) = each($this->$extra)) {
    for ($i=0;$i<3;$i++) {
    echo "<tr class=\"tl\">";
    echo "<td>$counter[$i]</td>";
    echo "</tr>";
    }
}
}

On one page, I need a table printed out. The data for this is in an array:

$page->extra = array( array('Track no.', 'Track title', 'Track length'),
                      array('01', 'Value1', 'No1'),
                      array('02', 'Value2', 'No2'),
                      array('03', 'Value3', 'No3'),
                      array('04', 'Value4', 'No4'),
                      array('05', 'Value5', 'No5'),
                      array('06', 'Value6', 'No6'),
                      array('07', 'Value7', 'No7'),
                      array('08', 'Value8', 'No8'),
                      array('09', 'Value9', 'No9'),
                      array('10', 'Value10', 'No10'),
                      array('11', 'Value11', 'No11'),
                      array('12', 'Value12', 'No12')
                     );

The errors I’m getting are:

Notice: Undefined variable: extra in C:\wamp\www\test\class_lib.php on line 47

…and:

Fatal error: Cannot access empty property in C:\wamp\www\test\class_lib.php on line 47

Here’s the full class_lib.php file if needed:
http://pastebin.com/7XRjDKVU

…and the index.php:
http://pastebin.com/yHBYpNxd

I hope I’ve given enough information there – I’d appreciate any help.

  • 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-25T06:51:44+00:00Added an answer on May 25, 2026 at 6:51 am

    you misstyped variable:

    while (list($counter) = each($this->$extra)) {
    

    should be

    while (list($counter) = each($this->extra)) {
    

    look at $this->extra

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

Sidebar

Related Questions

[Disclaimer: I am new to PHP, and I am just learning, so please no
Disclaimer: Never used php in my life. New to Unix and Jenkins I have
Disclaimer: I'm fairly new to python! If I want all the lines of a
Disclaimer: super new to rails. I'm using Rails 3.2 Anyways, I'm trying to create
Disclaimer : I'm new to web development. Scenario : I've built an application using
Disclaimer, I'm not a PHP programmer, so you might find this question trivial. That's
DISCLAIMER: relatively new to Flex/AS3, I might be missing something obvious. After doing some
Disclaimer: I'm very new to SQL and databases in general. I need to create
Disclaimer: I'm new to the REST school of thought, and I'm trying to wrap
DISCLAIMER - I am total PHP noob - looking for some help/tips on how

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.