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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:02:03+00:00 2026-06-11T11:02:03+00:00

I am having some problems with my php code: All information returns but I

  • 0

I am having some problems with my php code: All information returns but I cannot figure out why I am getting the error. For my index page I only inluded the line of code that is actually using that class there really is no other code other than some includes. Im sure it is how I built my __contstruct but i am not sure of the approriate way of doing it. I am missing something in how it is being called from the index page.

This line of code for my __construct works w/o error but I do not want the variable assigned in my class.

public function __construct(){
    $this->user_id = '235454';
    $this->user_type = 'Full Time Employee';


}

This is my Class

<?php 

class User
{
protected $user_id;
protected $user_type;
protected $name;
public $first_name;
public $last_name;
public $email_address;

public function __construct($user_id){
    $this->user_id = $user_id;
    $this->user_type = 'Full Time Employee';


}


public function __set($name, $value){
    $this->$name = $value;

}

public function __get($name){
    return $this->$name;

}

public function __destroy(){


}


 }

 ?>

This is my code from my index page:

<?php

ini_set('display_errors', 'On'); 
error_reporting(E_ALL);

 $employee_id = new User(2365);
 $employee_type = new User();   

echo 'Your employee ID is ' . '"' .$employee_id->user_id. '"' . ' your employement status is a n ' . '"' .$employee_type->user_type. '"';

echo '<br/>';

 ?>
  • 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-06-11T11:02:08+00:00Added an answer on June 11, 2026 at 11:02 am

    The problem is:

    $employee_type = new User();  
    

    the constructor expect one argument, but you send nothing.

    Change

    public function __construct($user_id) {
    

    to

    public function __construct($user_id = '') {
    

    See the outputs

    $employee_id = new User(2365);
    echo $employee_id->user_id; // Output: 2365
    echo $employee_id->user_type; // Output: Full Time Employee
    $employee_type = new User();
    echo $employee_type->user_id; // Output nothing
    echo $employee_type->user_type; // Output: Full Time Employee
    

    If you have one user, you can do this:

    $employer = new User(2365);
    $employer->user_type = 'A user type';
    
    echo 'Your employee ID is "' . $employer->user_id . '" your employement status is "' . $employer->user_type . '"';
    

    Which output:

    Your employee ID is "2365" your employement status is "A user type"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems with mod rewrite in the following configuration (simplified version): /index.php
I'm having some problems trying to figure out how to generate a Google Map
I'm trying to translate a javascript function into php but having some problems with
I'm having a problem with some code that used to work in PHP 4.X
I have a PHP application that I have been having some problems with, some
Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems
Im having some problems getting the Sticky Footer to work on my site. If
i am trying to do a guestbook in php but i am having some
I am building a website that runs all of the code trough index.php. For
PROBLEM : I am having problems getting socket.IO to connect in some circumstances, so

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.