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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:19:26+00:00 2026-05-23T19:19:26+00:00

I have a php script, test.php that has the contents <?php require_once(classes/user.php); echo test;

  • 0

I have a php script, test.php that has the contents

<?php
     require_once("classes/user.php");
     echo "test";
?>

and here is the contents of user.php

<?php 
class User {
    private $data = array();

    public function __set($name, $value) {
        $this->data[$name] = $value;
    }

    public function __get($name) {
        if (array_key_exists($name, $this->data)) {
            return $this->data[$name];
        }

        $trace = debug_backtrace();
        trigger_error(
            'Undefined property via __get(): ' . $name .
            ' in ' . $trace[0]['file'] .
            ' on line ' . $trace[0]['line'],
            E_USER_NOTICE);
        return null;
    }

    public function __isset($name) {
        return isset($this->data[$name]);
    }

    public function __unset($name) {
        unset($this->data[$name]);
    }

    public __construct($param) {
        if(is_array($param)) $this->create($param);
        else $this->id($param);
    }

    private id($id) { //select from database
        require_once('config.php');

        $pdo = new PDOConfig();

        $sql = "SELECT * FROM users WHERE `id` = :id";

        $q = $pdo->prepare($sql);
        $q->execute(array(":id"=>$id));
        $resp = $q->fetchAll();

        foreach ($resp as $row) {
            foreach ($row as $key=>$value) {
                if(!is_int($key))
                    $this->data[$key] = html_entity_decode($value, ENT_QUOTES);
            }
        }

        $pdo = null;
        unset($pdo);
    }

    private create($arr) { //create new item from values in array and insert to db

    }

    public delete() {
        $this->life = 0;
        //update database "life" here
    }   

    /* ##################################### */
    /* !Functions                            */
    /* ##################################### */

    public projects($extra = null) {
        $projects = array();
        require_once('project.php');

        $pdo = new PDOConfig();

        $sql = "SELECT * FROM ---- WHERE `000` = :aaa";

        if($extra) $sql .= " " . $extra;

        $q = $pdo->prepare($sql);
        $q->execute(array(":aaa"=>$this->id));
        $resp = $q->fetchAll();

        foreach ($resp as $row) {
                $project = new Project($row['id']);
                $projects[] = $project;

                $project = null;
                unset($project);
        }

        return $projects;
    }

}
?>

and test is never printed, and on chrome the page doesn’t load at all

The website encountered an error while retrieving http://example.com/test.php. It may be down for maintenance or configured incorrectly.

I can’t figure this out for the life of me. Thanks it advance

  • 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-23T19:19:27+00:00Added an answer on May 23, 2026 at 7:19 pm

    You have a syntax error in the declaration of your __construct() method :

    public __construct($param) {
        if(is_array($param)) $this->create($param);
        else $this->id($param);
    }
    

    You need to use the function keyword, like this :

    public function __construct($param) {
        if(is_array($param)) $this->create($param);
        else $this->id($param);
    }
    

    To help find those errors, on your development computer, you should enable :

    • error_reporting
    • and display_errors

    In fact, I just copy-pasted your code to a .php file and ran it — and got a nice

    Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE 
        in /home/.../temp/temp.php on line 39
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small script which im using to test PHP mail(), as below:
I have php script that creates a temporary watermark image for users that are
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that needs to determine if it's been executed via
I have a PHP script that initialises an image gallery. It loops through all
I have a PHP script that can encode a PNG image to a Base64
I have a PHP script that sends critical e-mails. I know how to check
I have a PHP script that processes file uploads. The script tries to organise
I have a php script which accesses a MSSQL2005 database, reads some data from
I have a PHP script (running on a Linux server) that ouputs the names

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.