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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:56:31+00:00 2026-05-31T15:56:31+00:00

<?php abstract class file { private $pid; private $uid; public function __construct($pid,$uid) { $this->pid

  • 0
<?php

abstract class file
{
    private $pid;
    private $uid;
    public function  __construct($pid,$uid)
    {
        $this->pid = $pid;
        $this->uid = $uid;
    }

    public function valid()
    {
        if($_SESSION['level']<$this->pid)
        {
            return true;
        }
        else
            return false;
    }
    public function allow()
    { 
        return "This is all right!";
    }

}
?>



    <?php
    // put your code here
    include("../file.php");
    session_start();
    class android extends file
    {
        public function __construct($pid,$uid)
        {
            parent::__construct($pid, $uid);

        }
    }

    $uid = $_SESSION['id'];
    $pa = new android(1,$uid);
    if($pa->valid())
            echo $pa->allow();
    else
            echo "<h1>No permission<h1>"

    ?>

The above class is android class and the one above that is file.. Now when the android extends(inherits) the file class, it means it has all the methods. But when I try to run the program, it says undefined variable android::allow()
I dont understand because I have defined the allow() function in the file class and so the android class should inherit the method as well.
please help.. Thanks in 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-31T15:56:32+00:00Added an answer on May 31, 2026 at 3:56 pm

    According to http://www.php.net/manual/en/language.oop5.abstract.php ,

    Classes defined as abstract may not be instantiated

    If your file class doesn’t have any abstract method, don’t bother declaring it as abstract, otherwise avoid calling the constructor 😉

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

Sidebar

Related Questions

class absclass { abstract public function fuc(); } reports: PHP Fatal error: Class absclass
I have created this file at My/View/Helper/FormElement.php <?php abstract class My_View_Helper_FormElement extends Zend_View_Helper_FormElement {
<?php require_once 'abstract.php'; class Mage_Shell_Snapshot extends Mage_Shell_Abstract { public function _snapshot() { if(!Mage::isInstalled()) {
Can I somehow do this in an abstract class in php: abstract function AddFilter();
According to the PHP manual , a class like this: abstract class Example {}
is it possible to do something like this in PHP 5.2.1? abstract class Test
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
<?php class PI_Controller_Plugin_AssetGrabber extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { /* The module
This is my user class: <? require_once(dirname(__FILE__).'/DB.class.php'); require_once(dirname(__FILE__).'/Model.class.php'); class Benutzer extends Model { private
Say I've got the following: <?php abstract class MyParent { public static $table_name; public

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.