Fatal error cannot make non static method

I was working on a PHP web application. I used a new datagrid from gurrido.net and it worked well on the local but when I upload it to the server, I get the following error: Fatal error: Cannot ...

I was working on a PHP web application. I used a new datagrid from gurrido.net and it worked well on the local but when I upload it to the server, I get the following error:

Fatal error: Cannot make non static method Base::getClassName() static
in class Singletons in /var/www/reskb/phpinc/Singletons.class.php on
line 84

In my old version where I didn’t use the grid, I got it working. Here is my code of singletons.class.php file:

<?
class Singletons extends Base {
    var $objects = array();
    function getClassName() {
        return 'Singletons';
    }
    function _instance() {
        static $_instance = NULL;
        if ($_instance == NULL) {
            $className = Singletons::getClassName();
            $_instance = new $className();
        }
        return $_instance;
    }
    function put($object) {
        $self = Singletons::_instance();
        $className = $object->getClassName();
        $self->objects[$className] = $object;
    }
    function get($className) {
        $self = Singletons::_instance();
        if(!empty($self->objects[$className]))
            return $self->objects[$className];
        else return '';
    }
}
Singletons::_instance();
?>

seaotternerd's user avatar

seaotternerd

6,2582 gold badges45 silver badges58 bronze badges

asked May 5, 2015 at 5:03

Hello Man's user avatar

2

You should call function getClassName using object or define getClassName as static. –

  <?php
    class Singletons extends Base {
        var $objects = array();
        static function  getClassName() {
            return 'Singletons';
        }
        static function _instance() {
            static $_instance = NULL;
            if ($_instance == NULL) {
                $className = Singletons::getClassName();
                $_instance = new $className();
            }
            return $_instance;
        }
        function put($object) {
            $self = Singletons::_instance();
            $className = $object->getClassName();
            $self->objects[$className] = $object;
        }
        function get($className) {
            $self = Singletons::_instance();
            if(!empty($self->objects[$className]))
                return $self->objects[$className];
            else return '';
        }
    }
    Singletons::_instance();
    ?>

answered May 5, 2015 at 5:11

Sanjay Kumar N S's user avatar

Sanjay Kumar N SSanjay Kumar N S

4,5474 gold badges22 silver badges38 bronze badges

4

You’re getting the error because you’re trying to call your function statically when it isn’t a static method (function).

You need to specify the function as static:

static function getClassName() {
    return 'Singletons';
}

That goes for every method you’d like to call statically.

answered May 5, 2015 at 5:11

Darren's user avatar

DarrenDarren

12.9k4 gold badges39 silver badges77 bronze badges

1

If you declare a function as abstract in an abstract super class, then attempt to define it as static in a child class, you will get a fatal error. You may want to think about the way your class hierarchy is structured, as your only option will be to remove the abstract function declaration from the super class.

answered Apr 28, 2019 at 6:04

Anthony Rutledge's user avatar

Anthony RutledgeAnthony Rutledge

6,5221 gold badge36 silver badges44 bronze badges

Обновление Битрикс

 

Добрый день.
После обновления получилось вот так

Fatal error: Cannot make static method CUserTypeEnum::GetUserTypeDescription() non static in class CUserTypeCustomIBlockElement in /home/bitrix/www/local/php_interface/classes/CUserTypeCustom­IBlockElement.php on line 20
[ErrorException] E_COMPILE_ERROR
Cannot make static method CUserTypeEnum::GetUserTypeDescription() non static in class CUserTypeCustomIBlockElement (0)
/home/bitrix/www/local/php_interface/classes/CUserTypeCustom­IBlockElement.php:20

Что не так с ним?

 

Пользователь 279792

Эксперт

Сообщений: 297
Баллов: 58
Авторитет:

1

Рейтинг пользователя:

0

Регистрация: 03.09.2014

Тут думаю только в ТП писать, они заменят файлы на эталонные

А может у вас перестали работать доп обработки в init.php или result_modifier.php

 

перед обновлением делал копию штатными средствами битры. Оттуда нельзя ничего забрать?

 

Пользователь 113480

Эксперт

Сообщений: 438
Баллов: 54
Авторитет:

1

Рейтинг пользователя:

0

Регистрация: 19.10.2012

#4

0

23.01.2022 13:37:38

Цитата
написал:
Fatal error: Cannot make static method CUserTypeEnum::GetUserTypeDescription() non static in class CUserTypeCustomIBlockElement in /home/bitrix/www/local/php_interface/classes/CUserTypeCustom­­IBlockElement.php on line 20

система ругается на кастомный класс CUserTypeCustom­IBlockElement
Соответственно ТП не поможет:

Цитата
написал:
Тут думаю только в ТП писать, они заменят файлы на эталонные

Что делать?
1. отключите все кастомные доработки (кк вариант переименуйте папку local -> __local)
2. см. файл: /local/php_interface/classes/CUserTypeCustom­IBlockElement.php on line 20
   ошибка генерится на 20-й строке.
PS. Если вы обновлялись, то скорее всего вы обновили PHP до 7.4
Возможно, что там используется код не поддерживаемый в 7.4.

 

php был обновлен до этого, где то еще в апреле. То есть на момент текущего обновления уже была версия php 7/4

 

Пользователь 2258759

Заглянувший

Сообщений: 10
Авторитет:

0

Рейтинг пользователя:

0

Регистрация: 15.10.2019

#6

0

23.01.2022 13:56:30

А вот когда local переименовал то страничка авторизации открылась. И вроде как заработало….

PHP class methods declared private are not accessible by child classes, but child classes can declare a method with the same name without having to adhere to Liskov Substitution Principle. PHP 8.0 strictly enforces method signatures, but private class methods are not affected by this change.

Typed Properties introduced in PHP 7.4 already follow the same changes, and is not changed in PHP 8.0.

Prior to PHP 8.0, it was not allowed change to change the final or static flags of a class method. This is changed in PHP 8.0, that ensures private methods can be truly private without adhering to the inheritance rules enforced from parent class(es).

In all PHP versions, private class method parameters, private method return types, and private class property types are not validated against Liskov Substitution Principle. These changes in PHP 8.0 only applies to changes in abstract, static, and final flags in class methods.

final private methods

Declaring a class method final private does not make sense because all private class methods are inaccessible by child classes anyway.

Prior to PHP 8.0, it was allowed to declare a class method as final private, but it was not allowed to redeclare the method due to final clause enforcement.

class Foo {
    final private function testFoo(): void {}
}

class ChildFoo extends Foo{
    private function testFoo(): void {}
}

This was not allowed prior to PHP 8.0, and resulted in a fatal error:

Fatal error: Cannot override final method Foo::testFoo() in ... on line ...

In PHP 8.0 and later, this restriction is removed, and only a warning is emitted:

Warning: Private methods cannot be final as they are never overridden by other classes in ... on line ...

Note that this warning is emitted when a class declares a method as final private; not when a child class re-declares a private method.

final private class constructors

An exception is made for the warning mentioned above for class constructors. It is possible to declare a class constructor as final private:

class Foo {
    final private function __construct() {}
}

Attempting to re-declare the constructor results in the same fatal error in all PHP versions.

class Foo {
    final private function __construct() {}
}

class ChildFoo extends Foo{
    final private function __construct() {}
}

// Fatal error: Cannot override final method Foo::__construct() in ... on line ...

static methods

Changing the static flag in an inheritance was not allow prior to PHP 8.0. It is allowed in PHP 8.0.

class Foo {
    private function bar() {}
    static private function baz() {}
}

class ChildFoo extends Foo{
    static private function bar() {} // Adds `static` flag from Foo
    private function baz() {} // Removes `static` flag from Foo
}

Prior to PHP 8.0, this caused fatal errors:

Fatal error: Cannot make non static method Foo::bar() static in class ChildFoo in ... on line ...
Fatal error: Cannot make static method Foo::baz() non static in class ChildFoo in ... on line ...

abstract methods

PHP does not allow to declare a private abstract function in any PHP version. In PHP 8.0 and later, it is allowed to declare a method as abstract even if a method with same name exists in the parent class.

class Foo {
    private function test() {}
}

abstract class ChildFoo extends Foo{
    abstract protected function test();
}

Prior to PHP 8.0, this resulted in a fatal error:

Fatal error: Cannot make non abstract method Foo::test() abstract in class ChildFoo in ... on line ...

Magic Methods

In PHP 8.0, magic method signatures are enforced. Magic methods (e.g __get, __set, __callStatic, etc) must follow the signature even if they are declared private.

Backwards Compatibility Impact

All private method signature patterns were not allowed and resulted in a fatal error in PHP versions prior to 8.0. As PHP 8.0 now allows it, these changes should not cause further errors in PHP 8.0

Declaring a class method final private emits a PHP warning at the declaration time of the parent class. This behavior is different from the fatal error that is only triggered if a child class attempted to extend/re-declare the same method.

Related Changes

  • Fatal errors on incompatible method signatures
  • Class magic method signatures are strictly enforced
  • Calling non-static class methods statically result in a fatal error

RFC Discussion Implementation

  1. Offline

    dron111

    Недавно здесь

    Регистрация:
    19.09.2012
    Сообщения:
    10
    Симпатии:
    0
    Пол:
    Мужской

    после бэкапа, при входе в «общие настройки» joomla выдает следущее:
    Fatal error: Cannot make non static method JCacheStorage::test() static in class JCacheStorageCachelite in /home/agrobonu/public_html/libraries/joomla/cache/storage/cachelite.php on line 334

    так же не могу войти в «менеджер плагинов», все остальное работает нормально.
    Может кто сталкивался, в гугле ничего путного не нашел!?

  2. woojin

    Offline

    woojin

    Местный
    Команда форума
    => Cпециалист <=

    Регистрация:
    31.05.2009
    Сообщения:
    3 206
    Симпатии:
    334
    Пол:
    Мужской

    там вот такая строка @include_once ‘Cache/Lite.php’;
    убери из неё знак «@»

    правда я такого файла не нешёл ни в 2.5 ни в 3.х версиях, но должно помоч

  3. Offline

    dron111

    Недавно здесь

    Регистрация:
    19.09.2012
    Сообщения:
    10
    Симпатии:
    0
    Пол:
    Мужской

    у меня старушка 1.5)) сейчас попробую

  4. OlegK

    Offline

    OlegK

    Russian Joomla! Team
    Команда форума
    ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    768
    Пол:
    Мужской

    Не понял, а куда делась аналогичная тема.Я же давал ответ со ссылкой на решение на форуме joomla.org
    Совет был убрать static из строки public static function test().
    Правда у меня строка 321 и J 2.5 ,а не J 1.5
    Замени этот файл cachelite.php ,а еще лучше удали /libraries и залей из чистого дистра J 2.5.x

  5. Offline

    dron111

    Недавно здесь

    Регистрация:
    19.09.2012
    Сообщения:
    10
    Симпатии:
    0
    Пол:
    Мужской

    был там такой значок, но не помогло(( 2 сутки сижу с этой запарой…..

  6. OlegK

    Offline

    OlegK

    Russian Joomla! Team
    Команда форума
    ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    768
    Пол:
    Мужской

    Это не значок/директива @ ,а оператор подавления ошибок php.
    Ты обновлял J 1.5 до J 2.5 ?

  7. woojin

    Offline

    woojin

    Местный
    Команда форума
    => Cпециалист <=

    Регистрация:
    31.05.2009
    Сообщения:
    3 206
    Симпатии:
    334
    Пол:
    Мужской

    3.х

    1. public static function isSupported()
    2.         @include_once ‘Cache/Lite.php’;
    3.         if (class_exists(‘Cache_Lite’))

    2.5.х

    1. public static function test()
    2.         @include_once ‘Cache/Lite.php’;
    3.         if (class_exists(‘Cache_Lite’))

    1.5.х
    по этому пути libraries/joomla/cache/storage/ вообще нет такого файла cachelite.php

    значит это или 2.5.х или 3.х!!!

  8. Offline

    dron111

    Недавно здесь

    Регистрация:
    19.09.2012
    Сообщения:
    10
    Симпатии:
    0
    Пол:
    Мужской

    Совершенно верно woojin. заменил , только с версии 1.5.22 родной там оказывается такого файла вообще нет)) а вот в 2.5.7 есть и если его вкинуть та же ошибка выходит) спасибо за подсказку куда плюсик ставить?)))

    да я пробовал обновить до 2.5 но мне не понравился результат, сделал бэкап, но как это файл попал в него не пойму, я полностью на чистый хост восстанавливал)))

    Последнее редактирование модератором: 06.12.2012

  9. OlegK

    Offline

    OlegK

    Russian Joomla! Team
    Команда форума
    ⇒ Профи ⇐

    Регистрация:
    17.01.2011
    Сообщения:
    7 813
    Симпатии:
    768
    Пол:
    Мужской

    Пользуйся кнопкой Изменить, в сообщении.
    Так что Решено ?

Поделиться этой страницей


Форумы Joomla! CMS

Moderator: General Support Moderators

ivanmalo2

Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Fri Apr 23, 2010 12:54 pm

Fatal error: Cannot make non static method JCacheStorageHELP

Hi,
I just restored my joomla site from a backup done with akeeba and everything ran fine until I try to edit my general settings, there it sends me to a blank page with this error:

Code: Select all

Fatal error: Cannot make non static method JCacheStorage::test() static in class JCacheStorageCachelite in /home/qu1dwar3/public_html/truequeequino.com/libraries/joomla/cache/storage/cachelite.php on line 278

I dont even find this file in any joomla installation I’ve made.
I would apreciate any help, thanks.


grailking

Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jan 23, 2008 9:02 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by grailking » Tue Jun 01, 2010 8:42 pm

I have the same error on a brand new install of 1.5.18 on a centOS box.

Anybody have a clue as to where to go to fix it?


ivanmalo

Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Tue Jan 05, 2010 5:27 am

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by ivanmalo » Wed Jun 02, 2010 4:56 am

grailking wrote:I have the same error on a brand new install of 1.5.18 on a centOS box.

Anybody have a clue as to where to go to fix it?

I fixed it when I eliminated both chachelite.php and another file i believe winsomething.php, This worked for me but I dont think it was safe to do taht, backup your site before trying it.


grailking

Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jan 23, 2008 9:02 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by grailking » Wed Jun 02, 2010 1:16 pm

Since the site I’m working on isn’t a production site yet, I deleted cachelite.php & wincache.php and it worked for me as well.

I’m uneasy about deleting files I don’t understand myself — does anybody know what I just deleted and what effect it may have in the long term?


candise

Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Nov 22, 2010 4:45 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by candise » Mon Nov 22, 2010 4:48 pm

I tried deleting the files and came up with this error:

Fatal error: Cannot make non static method JCacheStorage::test() static in class JCacheStorageWincache in /hermes/web08/b1229/moo.playstartmusiccom/libraries/joomla/cache/storage/wincache.php on line 169

Ideas?


ProgeneSafe

Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jan 19, 2011 10:25 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by ProgeneSafe » Fri Feb 25, 2011 9:08 pm

Guys,

If you feel uneasy about deleting files you don’t know about, don’t delete them… just rename them, adding the extension ‘.old’ to the file. So, in this case, change /libraries/joomla/chache/storage/chachelite.php and wincache.php to cachelite.php.old and wincache.php.old and also /libraries/joomla/session/storage/wincache.php to wincache.php.old

It worked for me!

Thanks,

stylez


dale28

Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Apr 03, 2011 5:59 am

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by dale28 » Sun Apr 03, 2011 6:09 am

hey!
I just found a way to fix this problem.

here’s what i’ve done
for the file:/libraries/joomla/cache/storage/cachelite.php
open it and look for «funcion test()»
it’s normally at the bottom
find it and remove the word «static» in the same line

if there’s still problems with
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
do the similar thing to them

hope i do help :D


pearlcaviar

Joomla! Intern
Joomla! Intern
Posts: 62
Joined: Sat Dec 04, 2010 6:57 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by pearlcaviar » Fri Apr 08, 2011 8:09 am

Thanks for your post dale28. You save my life :p

dale28 wrote:hey!
I just found a way to fix this problem.

here’s what i’ve done
for the file:/libraries/joomla/cache/storage/cachelite.php
open it and look for «funcion test()»
it’s normally at the bottom
find it and remove the word «static» in the same line

if there’s still problems with
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
do the similar thing to them

hope i do help :D


User avatar

wbhendrix

Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Wed Oct 03, 2007 2:18 am
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by wbhendrix » Mon Apr 25, 2011 11:30 pm

thank you so much @Dale28 — this worked perfect!


User avatar

willisetech

Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Mar 08, 2010 5:51 pm
Location: Vernon, BC
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by willisetech » Tue May 24, 2011 2:54 pm

Thank you Dale28, this also worked for me. I needed to remove «static» from all the files you mentioned, then all was well.



Mass1

Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Aug 18, 2011 9:35 am

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by Mass1 » Thu Aug 18, 2011 9:42 am

dale28 wrote:hey!
I just found a way to fix this problem.

here’s what i’ve done
for the file:/libraries/joomla/cache/storage/cachelite.php
open it and look for «funcion test()»
it’s normally at the bottom
find it and remove the word «static» in the same line

if there’s still problems with
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
do the similar thing to them

hope i do help :D

Hi I tried this solution but don’t work properly for me, because I obtain a blank page now… have you an idea?
thanks
Massimiliano


maci

Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Mon Dec 04, 2006 7:54 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by maci » Wed Sep 21, 2011 3:37 pm

hey, I got the same probleme!
I resolved deleting these files:
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
/libraries/joomla/cache/storage/cachelite.php



User avatar

deck2deck

Joomla! Explorer
Joomla! Explorer
Posts: 281
Joined: Fri Feb 03, 2006 3:23 pm
Location: Georgia, United States

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by deck2deck » Wed Oct 19, 2011 8:06 pm

Awesome dale28…

I’ve been living without my Global Configuration since May but today I had to have it. I finally resolved to find an answer to this problem and yours worked!!!! Bless you, bless you… so glad to have my GC page back. YAY!!!

Be part of the solution — not part of the problem.


devananda

Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Mon Apr 04, 2011 12:54 am
Location: S. Korea

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by devananda » Wed Oct 26, 2011 6:01 am

ProgeneSafe wrote:Guys,

If you feel uneasy about deleting files you don’t know about, don’t delete them… just rename them, adding the extension ‘.old’ to the file. So, in this case, change /libraries/joomla/chache/storage/chachelite.php and wincache.php to cachelite.php.old and wincache.php.old and also /libraries/joomla/session/storage/wincache.php to wincache.php.old

It worked for me!

Thanks,

stylez

I tried what dale28 suggested, deleting «static» from the code but it didn’t work for me.

Then….

I tried what ProgeneSafe suggested and it worked!

Thanks ProgenSafe!


User avatar

greennud

Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Mon Mar 08, 2010 10:16 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by greennud » Thu Nov 03, 2011 4:19 pm

Thank you very much maci amd dale28


korb

Joomla! Intern
Joomla! Intern
Posts: 88
Joined: Thu Apr 03, 2008 3:58 pm
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by korb » Mon Nov 07, 2011 12:34 pm

I am now with Joomla! 1.5.24 and none of the above worked..

HMM!

I used Akeeba Kickstart for the first time to restore a subdomain and I just overwritten my Joomla! 1.5 main site files with Joomla! 1.7 files! Then I restored my Joomla! 1.5 back-up to my main site and I got this issue, cannot access Global Configuration, Plugin Manager and User Manager.

Then using FTP I’ve uploaded Joomla! 1.5.24 full stable package and overwritten all files again. Nonw Global Configuration and User Managet are still not available.

Global Configuration shows Cannot make static…. eror
User Manager page is blank..

Appreciate any help.
Danny


MrQ1954

Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 21, 2011 4:43 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by MrQ1954 » Mon Nov 21, 2011 4:52 pm

Good day all

I too have this problem with Joomal 1.5.22

I would like to try the advice given to change the files but I dont have a clue where to start

Would someone be kind enough to explain to a complete novice how I do this
Where do I gain access to the files

I guess there is a simple answer (always is when you know it!)

Thank you in advance

MrQ


User avatar

montano

Joomla! Ace
Joomla! Ace
Posts: 1183
Joined: Wed Aug 24, 2005 11:38 am
Location: Dallas, TX
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by montano » Sat Nov 26, 2011 7:40 pm

I renamed the libraries/joomla folder to joomla-old as a safety precaution and then uploaded a fresh version of this folder from the most recent Joomla 1.5.25 release.

This fixed my problem.

It appears that cachelite.php and wincache.php are no longer included in a new installation. I tried renaming those two files, but still had issues until I replaced the folder all together.


MrQ1954

Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 21, 2011 4:43 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by MrQ1954 » Sat Nov 26, 2011 7:53 pm

Thank you Montano.

Very helpful.

I am am complete novice at this — can you please explain to me very briefly how I access the libraries and other files. Where do I start — I have tried everywhere I can think but cannot get into anything that looks like code

I appreciate any help on this

Thank you
MrQ


dia2000

Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Sat Jan 16, 2010 11:06 am
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by dia2000 » Sat Nov 26, 2011 8:21 pm

Thank you montano.
It didn’t work with me even!

But thanks anyway…


User avatar

montano

Joomla! Ace
Joomla! Ace
Posts: 1183
Joined: Wed Aug 24, 2005 11:38 am
Location: Dallas, TX
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by montano » Sat Nov 26, 2011 11:19 pm

You will need FTP access. Something like Filezilla or SmartFTP. Look at your Joomla file structure and find the folder called libraries. Follow the path in the error (libraries/joomla/cache/storage/)

MrQ1954 wrote:Thank you Montano.

Very helpful.

I am am complete novice at this — can you please explain to me very briefly how I access the libraries and other files. Where do I start — I have tried everywhere I can think but cannot get into anything that looks like code

I appreciate any help on this

Thank you
MrQ


MrQ1954

Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Nov 21, 2011 4:43 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by MrQ1954 » Sun Nov 27, 2011 1:53 am

Thnak you Montano — again
Very helpful and also timely

MrQ


maxoutje

Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sat Mar 20, 2010 8:33 am

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by maxoutje » Mon Nov 28, 2011 12:21 pm

Mass1 wrote:

dale28 wrote:hey!
I just found a way to fix this problem.

here’s what i’ve done
for the file:/libraries/joomla/cache/storage/cachelite.php
open it and look for «funcion test()»
it’s normally at the bottom
find it and remove the word «static» in the same line

if there’s still problems with
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
do the similar thing to them

hope i do help :D

Hi I tried this solution but don’t work properly for me, because I obtain a blank page now… have you an idea?
thanks
Massimiliano

Hi! i have also this problem ! I have a blank page on USERMANGER and CONFIGURATION.
Who has a solution?


User avatar

rholzler

Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Thu Feb 26, 2009 3:51 pm
Location: Sarasota, FL
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by rholzler » Wed Nov 30, 2011 5:27 pm

Renaming the old folders and uploading the same folders from the latest version of Joomla worked for me.


korb

Joomla! Intern
Joomla! Intern
Posts: 88
Joined: Thu Apr 03, 2008 3:58 pm
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by korb » Sat Dec 03, 2011 8:27 pm

montano wrote:You will need FTP access. Something like Filezilla or SmartFTP. Look at your Joomla file structure and find the folder called libraries. Follow the path in the error (libraries/joomla/cache/storage/)

MrQ1954 wrote:Thank you Montano.

Very helpful.

I am am complete novice at this — can you please explain to me very briefly how I access the libraries and other files. Where do I start — I have tried everywhere I can think but cannot get into anything that looks like code

I appreciate any help on this

Thank you
MrQ

This only works for Global Configuration, not User Manager :(


Fonias

Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Nov 16, 2009 1:19 am
Location: Ελλάδα
Contact:

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by Fonias » Sat Dec 31, 2011 9:26 pm

rholzler wrote:Renaming the old folders and uploading the same folders from the latest version of Joomla worked for me.

I used this trick and it worked for me too!

Thanx!


jacksprat

Joomla! Explorer
Joomla! Explorer
Posts: 283
Joined: Sun Jun 08, 2008 7:46 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by jacksprat » Thu May 17, 2012 8:55 pm

ProgeneSafe wrote:Guys,

If you feel uneasy about deleting files you don’t know about, don’t delete them… just rename them, adding the extension ‘.old’ to the file. So, in this case, change /libraries/joomla/chache/storage/chachelite.php and wincache.php to cachelite.php.old and wincache.php.old and also /libraries/joomla/session/storage/wincache.php to wincache.php.old

It worked for me!

Thanks,

stylez

Yes, and for me also!!! thanks


partopia

Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Jan 02, 2013 4:46 pm

Re: Fatal error: Cannot make non static method JCacheStorage

Post

by partopia » Wed Jan 02, 2013 4:52 pm

pearlcaviar wrote:Thanks for your post dale28. You save my life :p

dale28 wrote:hey!
I just found a way to fix this problem.

here’s what i’ve done
for the file:/libraries/joomla/cache/storage/cachelite.php
open it and look for «funcion test()»
it’s normally at the bottom
find it and remove the word «static» in the same line

if there’s still problems with
/libraries/joomla/cache/storage/wincache.php
/libraries/joomla/session/storage/wincache.php
do the similar thing to them

hope i do help :D

Deleting work for me, but only for the global config files….i am now getting a blank screen when i try to access user manager. Please help



Return to “Performance — Joomla! 1.5”


Jump to

  • Joomla! Announcements
  • ↳   Announcements
  • ↳   Announcements Discussions
  • Joomla! 4.x — Ask Support Questions Here
  • ↳   General Questions/New to Joomla! 4.x
  • ↳   Installation Joomla! 4.x
  • ↳   Administration Joomla! 4.x
  • ↳   Migrating and Upgrading to Joomla! 4.x
  • ↳   Extensions for Joomla! 4.x
  • ↳   Security in Joomla! 4.x
  • ↳   Templates for Joomla! 4.x
  • ↳   Search Engine Optimization (Joomla! SEO) in Joomla! 4.x
  • ↳   Language — Joomla! 4.x
  • ↳   Performance — Joomla! 4.x
  • ↳   Joomla! 4.x Coding
  • Joomla! 3.x — Ask Support Questions Here
  • ↳   General Questions/New to Joomla! 3.x
  • ↳   Installation Joomla! 3.x
  • ↳   Joomla! 3.x on IIS webserver
  • ↳   Administration Joomla! 3.x
  • ↳   Access Control List (ACL) in Joomla! 3.x
  • ↳   Migrating and Upgrading to Joomla! 3.x
  • ↳   Security in Joomla! 3.x
  • ↳   Extensions for Joomla! 3.x
  • ↳   Templates for Joomla! 3.x
  • ↳   Search Engine Optimization (Joomla! SEO) in Joomla! 3.x
  • ↳   Language — Joomla! 3.x
  • ↳   Performance — Joomla! 3.x
  • ↳   Joomla! 3.x Coding
  • Joomla! Versions which are End of Life
  • ↳   Joomla! 2.5 — End of Life 31 Dec 2014
  • ↳   General Questions/New to Joomla! 2.5
  • ↳   Installation Joomla! 2.5
  • ↳   Joomla! 2.5 on IIS webserver
  • ↳   Administration Joomla! 2.5
  • ↳   Access Control List (ACL) in Joomla! 2.5
  • ↳   Migrating and Upgrading to Joomla! 2.5
  • ↳   Security in Joomla! 2.5
  • ↳   Extensions for Joomla! 2.5
  • ↳   Templates for Joomla! 2.5
  • ↳   Search Engine Optimization (Joomla! SEO) in Joomla! 2.5
  • ↳   Language — Joomla! 2.5
  • ↳   Performance — Joomla! 2.5
  • ↳   Joomla! 1.5 — End of Life Sep 2012
  • ↳   General Questions/New to Joomla! 1.5
  • ↳   Installation 1.5
  • ↳   Joomla! 1.5 on IIS webserver
  • ↳   Administration 1.5
  • ↳   Migrating and Upgrading to Joomla! 1.5
  • ↳   Security in Joomla! 1.5
  • ↳   Extensions for Joomla! 1.5
  • ↳   Templates for Joomla! 1.5
  • ↳   Search Engine Optimization (Joomla! SEO) in Joomla! 1.5
  • ↳   Language — Joomla! 1.5
  • ↳   Performance — Joomla! 1.5
  • ↳   Joomla! 1.0 — End of Life 22 July 2009
  • ↳   Installation — 1.0.x
  • ↳   Upgrading — 1.0.x
  • ↳   Security — 1.0.x
  • ↳   3rd Party/Non Joomla! Security Issues
  • ↳   Administration — 1.0.x
  • ↳   Extensions — 1.0.x
  • ↳   Components
  • ↳   Modules
  • ↳   Plugins/Mambots
  • ↳   WYSIWYG Editors — 1.0.x
  • ↳   Integration & Bridges — 1.0.x
  • ↳   phpbb — Joomla! Integration
  • ↳   Templates & CSS — 1.0.x
  • ↳   Language — 1.0.x
  • ↳   Joom!Fish and Multilingual Sites
  • ↳   Performance — 1.0.x
  • ↳   General Questions — 1.0.x
  • Joomla! International Language Support
  • ↳   International Zone
  • ↳   Arabic Forum
  • ↳   تنبيهات هامة
  • ↳   الدروس
  • ↳   4.x جوملا!
  • ↳   جوملا! 1.6/1.7
  • ↳   الأسئلة الشائعة
  • ↳   التثبيت و الترقية
  • ↳   الحماية — و تحسين السرعة والأداء
  • ↳   لوحة التحكم
  • ↳   الإضافات البرمجية
  • ↳   تعريب جوملا! و الإضافات البرمجية
  • ↳   القوالب و التصميم
  • ↳   صداقة محركات البحث
  • ↳   القسم العام
  • ↳   1.5 !جوملا
  • ↳   الأسئلة الشائعة
  • ↳   التثبيت و الترقية
  • ↳   الحماية — و تحسين السرعة والأداء
  • ↳   لوحة التحكم
  • ↳   الإضافات البرمجية
  • ↳   تعريب جوملا! و الإضافات البرمجية
  • ↳   القوالب و التصميم
  • ↳   صداقة محركات البحث
  • ↳   القسم العام
  • ↳   جوملا! 1.0
  • ↳   الأسئلة الشائـعة
  • ↳   التثبيت
  • ↳   لوحة التحكم
  • ↳   الإضافات البرمجية
  • ↳   الإضافات المعرّبة
  • ↳   القوالب و التصميم
  • ↳   الحماية — تحسين السرعة والأداء — صداقة محركات البحث
  • ↳   القسم العام
  • ↳   القسم العام
  • ↳   !عرض موقعك بجوملا
  • ↳   الأرشيف
  • ↳   Bengali Forum
  • ↳   Bosnian Forum
  • ↳   Joomla! 1.5
  • ↳   Instalacija i prvi koraci
  • ↳   Ekstenzije
  • ↳   Templejti
  • ↳   Moduli
  • ↳   Prevodi i dokumentacija
  • ↳   Joomla! 1.7 / Joomla! 1.6
  • ↳   Catalan Forum
  • ↳   Notícies
  • ↳   Temes sobre l’administració
  • ↳   Temes sobre la traducció
  • ↳   Components, mòduls i joombots
  • ↳   Temes de disseny
  • ↳   Webs realitzades amb Joomla!
  • ↳   Offtopics
  • ↳   Chinese Forum
  • ↳   Croatian Forum
  • ↳   Danish Forum
  • ↳   Meddelelser
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x (Anbefalet til nye installationer. Nyeste funktionalitet)
  • ↳   Installation, backup, opdatering og flytning — Godt igang
  • ↳   Administration — Generel brug
  • ↳   Komponenter, Moduler og Plugins
  • ↳   Template, CSS og Design
  • ↳   Nethandel, betaling m.m.
  • ↳   Ældre versioner (disse vedligeholdes ikke længere fra officiel side)
  • ↳   Joomla! 2.5 (Supporteres indtil 31. dec. 2014)
  • ↳   Installation, backup, opdatering og flytning — Godt igang
  • ↳   Administration — Generel brug
  • ↳   Komponenter, Moduler og Plugins
  • ↳   Template, CSS og Design
  • ↳   Nethandel, betaling m.m.
  • ↳   Joomla 1.5 (Tidligere langtidssupporteret version indtil sep. 2012)
  • ↳   Installation, backup, opdatering og flytning — Godt igang
  • ↳   Administration — Generel brug
  • ↳   Komponenter, Moduler og Plugins
  • ↳   Template, CSS og Design
  • ↳   Nethandel, betaling m.m.
  • ↳   Joomla 1.0 (Udgået version, der blev afløst af 1.5 i 2008)
  • ↳   Installation, backup, opdatering og flytning — Godt igang
  • ↳   Administration — Generel brug
  • ↳   Komponenter, Moduler og Mambots
  • ↳   Template, CSS og Design
  • ↳   Nethandel, betaling m.m.
  • ↳   Oversættelser (lokalisering)
  • ↳   Joomla brugergrupper i Danmark
  • ↳   JUG Kolding
  • ↳   JUG København
  • ↳   JUG Odense
  • ↳   JUG Århus
  • ↳   JUG Sorø
  • ↳   Kommerciel (betalt) hjælp ønskes
  • ↳   SEO
  • ↳   FAQ — Dokumentation og vejledninger
  • ↳   Vis dit websted
  • ↳   Afviste ‘Vis dit websted’ indlæg
  • ↳   Diverse (Off topic)
  • ↳   Dutch Forum
  • ↳   Aankondigingen
  • ↳   Algemene vragen
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Installatie 3.x
  • ↳   Extensies 3.x
  • ↳   Templates 3.x
  • ↳   Joomla! 2.5
  • ↳   Installatie 2.5
  • ↳   Componenten 2.5
  • ↳   Modules 2.5
  • ↳   Plugins 2.5
  • ↳   Templates 2.5
  • ↳   Joomla! 1.5
  • ↳   Installatie
  • ↳   Componenten
  • ↳   Modules
  • ↳   Plugins
  • ↳   Templates
  • ↳   Joomla! 1.0
  • ↳   Installatie 1.0.x
  • ↳   Componenten 1.0.x
  • ↳   Modules 1.0.x
  • ↳   Mambots 1.0.x
  • ↳   Templates 1.0.x
  • ↳   Vertalingen
  • ↳   Offtopic
  • ↳   Show jouw website
  • ↳   Filipino Forum
  • ↳   International Support Center
  • ↳   Pinoy General Discussion & Archives
  • ↳   Site Showcase
  • ↳   Events
  • ↳   Design Tips and Tricks
  • ↳   Tsismis Zone
  • ↳   Pinoy Translation Zone
  • ↳   Pinoy Forum Archives
  • ↳   Joomla! Philippines Local Forum www.joomla.org.ph
  • ↳   Finnish Forum
  • ↳   French Forum
  • ↳   Les annonces!
  • ↳   Le bistrot!
  • ↳   L’expo!
  • ↳   J! 4.x — L’atelier!
  • ↳   J! 3.x — L’atelier!
  • ↳   3.x — Questions générales, nouvel utilisateur
  • ↳   3.x — Installation, migration et mise à jour
  • ↳   3.x — Sécurité et performances
  • ↳   3.x — Extensions tierce partie
  • ↳   3.x — Templates et design
  • ↳   3.x — Développement
  • ↳   3.x — Ressources
  • ↳   J! 2.5.x — L’atelier!
  • ↳   2.5 — Questions générales
  • ↳   2.5 — Installation, migration et mise à jour
  • ↳   2.5 — Sécurité et performances
  • ↳   2.5 — Extensions tierce partie
  • ↳   2.5 — Templates et design
  • ↳   2.5 — Développement
  • ↳   2.5 — Ressources
  • ↳   J! 1.5.x — L’atelier!
  • ↳   1.5 — Questions générales
  • ↳   1.5 — Installation, migration et mise à jour
  • ↳   1.5 — Sécurité et performances
  • ↳   1.5 — Extensions tierce partie
  • ↳   1.5 — Templates et design
  • ↳   1.5 — Développement
  • ↳   1.5 — Ressources
  • ↳   J! 1.0.x — L’atelier!
  • ↳   1.0 — Questions générales
  • ↳   1.0 — Installation et mise à jour
  • ↳   1.0 — Sécurité
  • ↳   1.0 — Extensions tierce partie
  • ↳   1.0 — Templates et design
  • ↳   1.0 — Développement
  • ↳   1.0 — Ressources
  • ↳   Besoin d’un professionel ?
  • ↳   Extensions Open Source pour Joomla!
  • ↳   German Forum
  • ↳   Ankündigungen
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Allgemeine Fragen
  • ↳   Installation und erste Schritte
  • ↳   Komponenten, Module, Plugins
  • ↳   Template, CSS und Designfragen
  • ↳   Entwicklerforum
  • ↳   Zeige Deine Webseite
  • ↳   Joomla! 2.5
  • ↳   Allgemeine Fragen
  • ↳   Installation und erste Schritte
  • ↳   Komponenten, Module, Plugins
  • ↳   Template, CSS und Designfragen
  • ↳   Entwicklerforum
  • ↳   Zeige Deine Webseite
  • ↳   Joomla! 1.5
  • ↳   Allgemeine Fragen
  • ↳   Installation und erste Schritte
  • ↳   Komponenten, Module, Plugins
  • ↳   Template, CSS und Designfragen
  • ↳   Entwicklerforum
  • ↳   Zeige Deine Webseite
  • ↳   Professioneller Service
  • ↳   Sonstiges (Offtopic)
  • ↳   Archiv
  • ↳   Joomla! 1.0
  • ↳   Allgemeine Fragen 1.0.x
  • ↳   Installation und erste Schritte 1.0.x
  • ↳   Komponenten, Module, Mambots 1.0.x
  • ↳   Template, CSS und Designfragen 1.0.x
  • ↳   Entwicklerforum 1.0.x
  • ↳   Zeige Deine Webseite 1.0.x
  • ↳   Greek Forum
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Joomla! 2.5.x
  • ↳   Joomla! 1.5.x
  • ↳   Joomla! 1.0.x
  • ↳   Hebrew Forum
  • ↳   Indic Languages Forum
  • ↳   Indonesian Forum
  • ↳   FAQ
  • ↳   Bantuan
  • ↳   Komponen
  • ↳   Modul
  • ↳   Template
  • ↳   Diskusi
  • ↳   Italian Forum
  • ↳   Guide
  • ↳   Traduzioni
  • ↳   Componenti — Moduli — Plugins
  • ↳   Template — Grafica
  • ↳   Notizie
  • ↳   Prodotti Open Source per Joomla!
  • ↳   Richieste professionali
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Joomla! 2.5.x
  • ↳   Joomla! 1.x
  • ↳   Latvian Forum
  • ↳   Lithuanian Forum
  • ↳   Joomla! 4.x
  • ↳   Joomla! 1.5
  • ↳   Joomla! 1.7 / Joomla! 1.6
  • ↳   Joomla! 1.0
  • ↳   Vertimai ir Kalba
  • ↳   Malaysian Forum
  • ↳   Solved
  • ↳   Norwegian Forum
  • ↳   Informasjon
  • ↳   Arkiverte annonseringer
  • ↳   FAQ — Ofte spurte spørsmål
  • ↳   Arkiv
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Administrasjon/installasjon
  • ↳   Migrering/Oppdatering
  • ↳   Template, CSS og design
  • ↳   Komponenter/moduler/programutvidelser
  • ↳   Sikkerhet
  • ↳   Generelt
  • ↳   Netthandel, betaling m.m.
  • ↳   VirtueMart
  • ↳   Andre nettbutikkløsninger
  • ↳   Generelt
  • ↳   Oversettelser
  • ↳   Fremvisning av sider (Show off)
  • ↳   Avviste fremvisninger
  • ↳   Diverse (off topic)
  • ↳   Kommersiell hjelp ønskes
  • ↳   Eldre versjoner av Joomla!
  • ↳   Joomla! 1.0
  • ↳   Administrasjon/installasjon
  • ↳   Template, CSS og design
  • ↳   Komponenter/moduler/mambots
  • ↳   Sikkerhet
  • ↳   Generelt
  • ↳   Joomla! 1.5
  • ↳   Administrasjon/installasjon
  • ↳   Migrering/Oppdatering
  • ↳   Template, CSS og design
  • ↳   Komponenter/moduler/programutvidelser
  • ↳   Sikkerhet
  • ↳   Generelt
  • ↳   Joomla! 2.5
  • ↳   Administrasjon/installasjon
  • ↳   Migrering/Oppdatering
  • ↳   Template, CSS og design
  • ↳   Komponenter/moduler/programutvidelser
  • ↳   Sikkerhet
  • ↳   Generelt
  • ↳   Persian Forum
  • ↳   قالب ها
  • ↳   مدیریت
  • ↳   سوالهای عمومی
  • ↳   نصب
  • ↳   مامبوت ها
  • ↳   ماژولها
  • ↳   کامپوننت ها
  • ↳   Polish Forum
  • ↳   Instalacja i aktualizacja
  • ↳   Administracja
  • ↳   Komponenty, moduły, wtyczki
  • ↳   Szablony
  • ↳   Paczta i Podziwiajta
  • ↳   Modyfikacje i własne rozwiązania
  • ↳   Tłumaczenia
  • ↳   FAQ
  • ↳   Tips&Tricks
  • ↳   Dokumentacja
  • ↳   Profesjonalne usługi
  • ↳   Portuguese Forum
  • ↳   Componentes, módulos e mambots
  • ↳   Programação e desenvolvimento
  • ↳   Segurança
  • ↳   Sites dos usuários
  • ↳   Off-topic
  • ↳   Tradução
  • ↳   Templates
  • ↳   Romanian Forum
  • ↳   Traduceri
  • ↳   Russian Forum
  • ↳   Объявления по Joomla!
  • ↳   Безопасность Joomla!
  • ↳   Joomla 4.x — Задайте здесь свой вопрос по поддержке
  • ↳   Joomla 3.x — Задайте здесь свой вопрос по поддержке
  • ↳   Общие вопросы/Новичок в Joomla! 3.x
  • ↳   Установка Joomla! 3.x
  • ↳   Миграция и переход на Joomla! 3.x
  • ↳   Расширения для Joomla! 3.x
  • ↳   Многоязычные веб-сайты на Joomla 3.x
  • ↳   Joomla 2.5 — Задайте здесь свой вопрос по поддержке
  • ↳   Общие вопросы/Новичок в Joomla! 2.5
  • ↳   Установка Joomla! 2.5
  • ↳   Расширения для Joomla! 2.5
  • ↳   Русский язык Joomla! 2.5
  • ↳   Serbian/Montenegrin Forum
  • ↳   Tehnička pitanja
  • ↳   Instalacija i početnička pitanja
  • ↳   Šabloni
  • ↳   Prevod i dokumentacija
  • ↳   Ćaskanje
  • ↳   Bezbednost
  • ↳   Joomla! dodaci
  • ↳   Pravna pitanja
  • ↳   Arhiva
  • ↳   Joomla! Događaji i Zajednica
  • ↳   Izlog (spisak) sajtova radjenih u Joomla! CMS-u
  • ↳   Profesionalne usluge
  • ↳   Slovak Forum
  • ↳   Spanish Forum
  • ↳   Joomla! 4.x
  • ↳   Joomla! 3.x
  • ↳   Migración y actualización a Joomla 3.x
  • ↳   Versiones de Joomla! obsoletas
  • ↳   Joomla! 2.5
  • ↳   Joomla! 1.5
  • ↳   Extensiones
  • ↳   Plantillas (templates) y diseño
  • ↳   Idioma y traducciones
  • ↳   SEO para Joomla!
  • ↳   Seguridad y rendimiento
  • ↳   Productos de Código Abierto para Joomla!
  • ↳   Servicios profesionales
  • ↳   Salón de la comunidad Ñ
  • ↳   Swedish Forum
  • ↳   Meddelanden
  • ↳   Forum Joomla! 4.x
  • ↳   Forum Joomla! 3.x
  • ↳   Allmänna frågor
  • ↳   Användning och administration
  • ↳   Installation, backup och säkerhet
  • ↳   Komponenter, moduler och plugin
  • ↳   Mallar (templates) och design
  • ↳   Äldre versioner
  • ↳   Forum Joomla! 1.0
  • ↳   Allmänna frågor
  • ↳   Användning och administration
  • ↳   Installation, backup och säkerhet
  • ↳   Komponenter, moduler och Mambots
  • ↳   Mallar (templates) och design
  • ↳   Forum Joomla! 1.7 / Joomla! 1.6
  • ↳   Allmänna frågor
  • ↳   Användning och administration
  • ↳   Installation, backup och säkerhet
  • ↳   Komponenter, moduler och plugin
  • ↳   Mallar (templates) och design
  • ↳   Forum Joomla! 1.5
  • ↳   Allmänna frågor
  • ↳   Användning och administration
  • ↳   Installation, backup och säkerhet
  • ↳   Komponenter, moduler och plugin
  • ↳   Mallar (templates) och design
  • ↳   Forum Joomla! 2.5
  • ↳   Allmänna frågor
  • ↳   Användning och administration
  • ↳   Installation, backup och säkerhet
  • ↳   Komponenter, moduler och plugin
  • ↳   Mallar (templates) och design
  • ↳   Översättning
  • ↳   Webbplatser gjorda i Joomla
  • ↳   Webbplatser J! 3.x
  • ↳   Webbplatser J! 2.5
  • ↳   Webbplatser Joomla! 1.7 / Joomla! 1.6
  • ↳   Webbplatser J! 1.5
  • ↳   Webbplatser J! 1.0
  • ↳   Kommersiell hjälp önskas
  • ↳   Diverse (off topic)
  • ↳   Tamil Forum
  • ↳   Thai Forum
  • ↳   โชว์เว็บไซต์ของคุณที่สร้างด้วยจูมล่า
  • ↳   เคล็ดลับการใช้งานส่วนต่างๆ เกี่ยวกับจ&#
  • ↳   คอมโพเน้นท์ โมดูล ปลักอิน ต่างๆ ที่ติดตั
  • ↳   อับเดดข่าวสารเกี่ยวกับจูมล่าลายไทย
  • ↳   Turkish Forum
  • ↳   Duyurular
  • ↳   Dersler
  • ↳   Genel Sorular
  • ↳   Bileşen, Modül, Bot
  • ↳   Eklenti Haberleri
  • ↳   Temalar
  • ↳   Vietnamese Forum
  • ↳   Gặp gỡ và giao lưu
  • ↳   Joomla Tiếng Việt
  • ↳   Cài đặt — Cấu hình
  • ↳   Thành phần mở rộng cho Joomla!
  • ↳   Hỏi đáp Joomla! 3.x
  • ↳   Hỏi đáp Joomla! 2.5
  • ↳   Hỗ trợ kỹ thuật
  • ↳   Bài viết cũ
  • ↳   Thiết kế Template
  • ↳   Joomla! 1.5
  • ↳   Hỏi đáp Joomla! 4.x
  • ↳   Welsh Forum
  • Other Forums
  • ↳   Open Source Products for Joomla!
  • ↳   The Lounge
  • ↳   Forum Post Assistant (FPA)
  • Joomla! Development Forums
  • Joomla! Official Sites & Infrastructure
  • ↳   docs.joomla.org — Feedback/Information
  • ↳   extensions.joomla.org — Feedback/Information
  • ↳   joomla.com — Feedback/Information
  • ↳   Sites & Infrastructure — Feedback/Information
  • ↳   Archived Boards — All boards closed
  • ↳   Design and Accessibility — Archived
  • ↳   Quality and Testing — Locked and Archived
  • ↳   Joomla! 1.0.x_Q&T
  • ↳   Q&T 1.0.x Resolved
  • ↳   Known Issues
  • ↳   Superseded Issues
  • ↳   Archive
  • ↳   Q&T 1.0.x Resolved — Archived
  • ↳   Known Issues — Archive
  • ↳   Superseded Issues — Archive
  • ↳   Joomla! 3.x Bug Reporting
  • ↳   Third Party Testing for Joomla! 1.5
  • ↳   Q&T 1.5.x Resolved
  • ↳   Joomla! 1.5 BETA
  • ↳   Joomla! 1.5 BETA 2
  • ↳   Reaction to the ‘Letter to the community’
  • ↳   Reaction to New Project Name
  • ↳   Logo Competition
  • ↳   Humor, Fun and Games
  • ↳   Libraries
  • ↳   patTemplate
  • ↳   com_connector — Multi Joomla Bridge
  • ↳   CiviCRM Support
  • ↳   CiviCRM Installation Issues
  • ↳   FAQ Archive
  • ↳   FAQ Discussion Board
  • ↳   3rd Party Extensions FAQ
  • ↳   FAQs not moved
  • ↳   3rd Party/Non Joomla! Security FAQ
  • ↳   Joomla! Coding 101
  • ↳   Joombie Tools of the Trade
  • ↳   Joombie Coding Q/A
  • ↳   Joombie Think Tank
  • ↳   Joombie Developer Lab
  • ↳   Joomla Forge — Archived
  • ↳   Non-Profit Organizations and Joomla!
  • ↳   Schools and Universities
  • ↳   Bangsamoro Forum
  • ↳   Joomla! 1.5 Template Contest
  • ↳   SMF — Simplemachines.org Forum
  • ↳   GPL Discussion
  • ↳   Security Announcements — Old
  • ↳   Tips & Tricks — Moving
  • ↳   Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.
  • ↳   Google Summer of Code and GHOP
  • ↳   Google Summer of Code 2008
  • ↳   Proposed projects
  • ↳   Student area
  • ↳   Past Google Summer of Code Editions
  • ↳   Google’s Highly Open Participation Contest
  • ↳   Documentation
  • ↳   Suggestions, Modifications, and Corrections
  • ↳   Archive
  • ↳   1.5 Archive
  • ↳   Suggestions, Modifications & Corrections
  • ↳   Submit
  • ↳   Feedback and Suggestions
  • ↳   Applications for participation in the Development Workgroup
  • ↳   Development
  • ↳   1.5 Site Showcase — Archived
  • ↳   1.0 x Site Showcase — Archived.
  • ↳   Feature Requests — White Papers — Archived
  • ↳   Under Review — Archived
  • ↳   Accepted — Archived
  • ↳   Not Accepted — Archived
  • ↳   Wishlists and Feature Requests — Archive
  • ↳   Wishlist Archives — Archived
  • ↳   Spanish Forum — Archive
  • ↳   Papelera
  • ↳   Tutoriales
  • ↳   General
  • ↳   Salón de la Joomlaesfera hispanohablante
  • ↳   Danish Forum — Archive
  • ↳   Diskussion af Meddelelser + Sikkerhedsmeddelelser + FAQ
  • ↳   Shop.Joomla.org
  • ↳   Joomla! 1.6 RC Support [closed]
  • ↳   Joomla! 1.0 Coding
  • ↳   Core Hacks and Patches
  • ↳   Joomla! 2.5 Beta Support
  • ↳   People.joomla.org — Feedback/Information
  • ↳   Joomla! 1.5 Bug Reporting
  • ↳   Joomla! 1.5 Coding
  • ↳   Joomla! 3 Beta Support
  • ↳   Trending Topics
  • ↳   Help wanted in the community
  • ↳   templates.joomla.org — Feedback/Information
  • ↳   Certification
  • ↳   Albanian Forum
  • ↳   Azeri Forum
  • ↳   Urdu Forum
  • ↳   Basque Forum
  • ↳   Itzulpenaren inguruan
  • ↳   Laguntza teknikoa
  • ↳   Belarusian Forum
  • ↳   Maltese Forum
  • ↳   Hungarian Forum
  • ↳   Slovenian Forum
  • ↳   Japanese Forum
  • ↳   Khmer Forum
  • ↳   ពិពណ៌​ស្ថាន​បណ្ដាញ​ជុំឡា
  • ↳   ជុំឡា​ខ្មែរ​មូលដ្ឋានីយកម្ម
  • ↳   Community Blog Discussions
  • ↳   JoomlaCode.org
  • ↳   Joomla! Marketing and PR Team
  • ↳   resources.joomla.org — Feedback/Information
  • ↳   Training.Joomla.org
  • ↳   OpenSourceMatters.org
  • ↳   magazine.joomla.org — Feedback/Information
  • ↳   Site Showcase
  • ↳   Joomla! 4 Related
  • ↳   Joomla! Events
  • ↳   Joomla! Ideas Forum
  • ↳   Registered Joomla! User Groups
  • ↳   Joomla! 2.5 Coding
  • ↳   Joomla! 2.5 Bug Reporting
  • ↳   User eXperience (UX)
  • ↳   Joomla! Working Groups
  • ↳   Translations

За последние 24 часа нас посетили 11447 программистов и 1168 роботов. Сейчас ищут 305 программистов …


  1. energy2008

    energy2008
    Активный пользователь

    С нами с:
    24 июн 2008
    Сообщения:
    47
    Симпатии:
    0

    Поставил PHP5, появилась новая ошибка при обращении к фунции pages из одноименного класса:
    Fatal error: Non-static method Pages::pages() cannot be called statically in X:homecms2wwwadmin.php on line 786

    Впервый сталкиваюсь с такой ошибкой. В чем может быть проблема?
    Функция выводит иерархию страниц у сайта и имеет следущий вид:
    $fa — ID старшей страницы
    $n — ID текушей страницы

    1.  function pages($fa,$n,$opt)  // вывод существующих страниц для редактирования
    2.           $mvr = mysql_query(«select * from 0pages where FATHER = $fa«);
    3.               $px = 20 * $n;  $px_menu = 12 * $n 5;          $n++;
    4.                    $URL = «/».($f[‘URL1’]!=«»?$f[‘URL1’].«/»:«»);
    5.                    if ((@$_GET[‘edit’]==$f[‘ID’])||(@$_GET[‘add’]==$f[‘ID’]))
    6.                        echo «<tr class='».$css.» plain».$cs.«‘ onMouseOver= «this.className= ‘».$css.» rollover».$cs.«‘; « onMouseOut= «this.className= ‘».$css.» plain».$cs.«‘; «  >»;
    7.                        echo «<td width=30% nowrap valign=center style=padding-left:».$px.«px;padding-right:20px;><a href=?add=».$f[‘ID’].«><img src=/images/add.gif border=0 height=10 alt=’добавить страницу’></a> «.$f[‘ID’].» &nbsp; «;
    8.                        echo «<a href=?edit=».$f[‘ID’].«><b>».$f[‘TITLE’].«</b></a></td> «;
    9.                        echo «<td width=* nowrap><a href=».$URL.«>».$URL.«</a></td>»;
    10.                        echo «<td width=30><a href=?edit=».$f[‘ID’].«>edit</a></td>»;
    11.                        echo «<td width=50 class=red><a href=?delete=».$f[‘ID’].«><font color=#FF3300><b>delete</b></font></a></td></tr>»;
    12.                        {     //  <start> обрезание длинных названий в меню
    13.                        $count_url = count(explode(«/», ($f[‘URL1’]!=«»?$f[‘URL1’].«/»:«»)));
    14.                        $line = (34 2 * $count_url);
    15.                        $f[‘TITLE’] =    (substr($f[‘TITLE’],0,$line)!=$f[‘TITLE’]?substr($f[‘TITLE’],0,$line).«..»:$f[‘TITLE’])  ;
    16.                              //  <end> обрезание длинных названий в меню
    17.                        echo «<div class='».$css.» plain2″.$cs.«‘ onMouseOver= «this.className= ‘».$css.» rollover2″.$cs.«‘; « onMouseOut= «this.className= ‘».$css.» plain2″.$cs.«‘; « «;
    18.                        echo «nowrap valign=center style=padding-left:».$px_menu.«px;padding-right:5px;><a href=?add=».$f[‘ID’].«><img src=/images/add_small.gif border=0 alt=’добавить страницу’ ></a> «.$f[‘ID’].» &nbsp; «;
    19.                        echo «<a href=?edit=».$f[‘ID’].«>».$f[‘TITLE’].«</a></div> «;
    20.                        Pages :: pages($f[‘ID’],$n,$opt);

    [/code]


  2. Sergey89

    Sergey89
    Активный пользователь

    С нами с:
    4 янв 2007
    Сообщения:
    4.796
    Симпатии:
    0

    1. public static function pages(


  3. mclaud

    mclaud
    Активный пользователь

    С нами с:
    15 фев 2007
    Сообщения:
    97
    Симпатии:
    0
    Адрес:
    Одесса

    Ты наверное пытаешься его вызвать, вот так:

    1. Pages::pages($fa,$n,$opt);

    Вместо, вот так:

    1. $pages->pages($fa,$n,$opt);

    Так что бы можно было так обращаться к методу класса, как в первом варианте, его нужно соответственно объявлять:

    1. public static function pages($fa,$n,$opt) {


  4. lexa

    lexa
    Активный пользователь

    energy2008, к вышесказаному добавлю: и поставь нормальную версию — PHP 5.2.*.

Содержание

  1. PHP 8.0: Calling non-static class methods statically result in a fatal error
  2. Variable Functions
  3. Callables
  4. is_callable
  5. static , self , and parent
  6. Backwards Compatibility Impact
  7. Php fatal error non static method
  8. Readonly classes
  9. Properties and methods
  10. extends
  11. Signature compatibility rules
  12. ::class
  13. Nullsafe methods and properties
  14. User Contributed Notes 13 notes

PHP 8.0: Calling non-static class methods statically result in a fatal error

PHP 8.0 no longer allows to call non-static class methods with the static call operator ( :: ).

Calling non-static methods statically raised a PHP deprecation notice in all PHP 7 versions, and raised a Strict Standards notice in PHP 5 versions.

In PHP 8.0 and later, this results in a fatal error:

Note that this only affects calling non-static methods statically. Although discouraged, calling a static method non-statically ( $this->staticMethod() ) is allowed.

This change is implemented throughout the engine.

Variable Functions

Callables

PHP no longer considers an array with class name and a method ( [‘Foo’, ‘bar’] ) as a valid callable, and results in a fatal error. This includes PHP core functions that expect a callable. If such callable is passed to a function that expects a valid callable, a TypeError will be thrown instead of a fatal error at call-time.

This affects all functions ranging from call_user_func and call_user_func_array to register_shutdown_function , set_error_handler , set_error_handler .

register_shutdown_function function in PHP 8.0 versions until beta3 raised a PHP warning at the time register_shutdown_function function is called instead of the current behavior of throwing a TypeError exception. This was corrected in PHP beta4.

is_callable

is_callable function returns false on callable that calls non-static methods statically. It returned true prior to PHP 8.0.

static , self , and parent

static , self , and and parent pointers can continue to use the static call syntax inside a class.

The call above is still allowed because static , self , and parent are used inside the class scope.

static:: and self:: calls are identical to $this-> calls on non-static methods, and improves readability. In the example above, static::foo() and self::foo() calls can be safely replaced with $this->foo() to improve readability because foo is not a static method.

Backwards Compatibility Impact

For existing code that get fatal errors in PHP 8.0, the fix can as simple as using the correct syntax if there is a class instance in the same scope.

If there is no instantiated class object, and if the class can be instantiated without any parameters or side effects, it will be simple replacement as well.

If the class constructor requires parameters, or tends to make any state changes, the fix can be more complicated. The instance needs to be injected to the scope the static call is made.

Note that functions that expect a callable parameter no longer accept callables with a non-static method as static method. A TypeError exception will be thrown when the callable is passed, as opposed to when the callable is invoked.

is_callable function no longer returns true for such callables either.

Источник

Php fatal error non static method

Basic class definitions begin with the keyword class , followed by a class name, followed by a pair of curly braces which enclose the definitions of the properties and methods belonging to the class.

The class name can be any valid label, provided it is not a PHP reserved word. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ^[a-zA-Z_x80-xff][a-zA-Z0-9_x80-xff]*$ .

A class may contain its own constants, variables (called «properties»), and functions (called «methods»).

Example #1 Simple Class definition

class SimpleClass
<
// property declaration
public $var = ‘a default value’ ;

// method declaration
public function displayVar () <
echo $this -> var ;
>
>
?>

The pseudo-variable $this is available when a method is called from within an object context. $this is the value of the calling object.

Calling a non-static method statically throws an Error . Prior to PHP 8.0.0, this would generate a deprecation notice, and $this would be undefined.

Example #2 Some examples of the $this pseudo-variable

class A
<
function foo ()
<
if (isset( $this )) <
echo ‘$this is defined (‘ ;
echo get_class ( $this );
echo «)n» ;
> else <
echo «$this is not defined.n» ;
>
>
>

$a = new A ();
$a -> foo ();

$b = new B ();
$b -> bar ();

Output of the above example in PHP 7:

Output of the above example in PHP 8:

Readonly classes

As of PHP 8.2.0, a class can be marked with the readonly modifier. Marking a class as readonly will add the readonly modifier to every declared property, and prevent the creation of dynamic properties. Moreover, it is impossible to add support for them by using the AllowDynamicProperties attribute. Attempting to do so will trigger a compile-time error.

#[AllowDynamicProperties]
readonly class Foo <
>

// Fatal error: Cannot apply #[AllowDynamicProperties] to readonly class Foo
?>

As neither untyped, nor static properties can be marked with the readonly modifier, readonly classes cannot declare them either:

// Fatal error: Readonly property Foo::$bar must have type
?>

class Foo
<
public static int $bar ;
>

// Fatal error: Readonly class Foo cannot declare static properties
?>

A readonly class can be extended if, and only if, the child class is also a readonly class.

To create an instance of a class, the new keyword must be used. An object will always be created unless the object has a constructor defined that throws an exception on error. Classes should be defined before instantiation (and in some cases this is a requirement).

If a string containing the name of a class is used with new , a new instance of that class will be created. If the class is in a namespace, its fully qualified name must be used when doing this.

If there are no arguments to be passed to the class’s constructor, parentheses after the class name may be omitted.

Example #3 Creating an instance

// This can also be done with a variable:
$className = ‘SimpleClass’ ;
$instance = new $className (); // new SimpleClass()
?>

As of PHP 8.0.0, using new with arbitrary expressions is supported. This allows more complex instantiation if the expression produces a string . The expressions must be wrapped in parentheses.

Example #4 Creating an instance using an arbitrary expression

In the given example we show multiple examples of valid arbitrary expressions that produce a class name. This shows a call to a function, string concatenation, and the ::class constant.

class ClassA extends stdClass <>
class ClassB extends stdClass <>
class ClassC extends ClassB <>
class ClassD extends ClassA <>

function getSomeClass (): string
<
return ‘ClassA’ ;
>

var_dump (new ( getSomeClass ()));
var_dump (new ( ‘Class’ . ‘B’ ));
var_dump (new ( ‘Class’ . ‘C’ ));
var_dump (new ( ClassD ::class));
?>

Output of the above example in PHP 8:

In the class context, it is possible to create a new object by new self and new parent .

When assigning an already created instance of a class to a new variable, the new variable will access the same instance as the object that was assigned. This behaviour is the same when passing instances to a function. A copy of an already created object can be made by cloning it.

Example #5 Object Assignment

$assigned = $instance ;
$reference =& $instance ;

$instance -> var = ‘$assigned will have this value’ ;

$instance = null ; // $instance and $reference become null

var_dump ( $instance );
var_dump ( $reference );
var_dump ( $assigned );
?>

The above example will output:

It’s possible to create instances of an object in a couple of ways:

Example #6 Creating new objects

class Test
<
static public function getNew ()
<
return new static;
>
>

class Child extends Test
<>

$obj1 = new Test ();
$obj2 = new $obj1 ;
var_dump ( $obj1 !== $obj2 );

$obj3 = Test :: getNew ();
var_dump ( $obj3 instanceof Test );

$obj4 = Child :: getNew ();
var_dump ( $obj4 instanceof Child );
?>

The above example will output:

It is possible to access a member of a newly created object in a single expression:

Example #7 Access member of newly created object

The above example will output something similar to:

Note: Prior to PHP 7.1, the arguments are not evaluated if there is no constructor function defined.

Properties and methods

Class properties and methods live in separate «namespaces», so it is possible to have a property and a method with the same name. Referring to both a property and a method has the same notation, and whether a property will be accessed or a method will be called, solely depends on the context, i.e. whether the usage is a variable access or a function call.

Example #8 Property access vs. method call

class Foo
<
public $bar = ‘property’ ;

public function bar () <
return ‘method’ ;
>
>

$obj = new Foo ();
echo $obj -> bar , PHP_EOL , $obj -> bar (), PHP_EOL ;

The above example will output:

That means that calling an anonymous function which has been assigned to a property is not directly possible. Instead the property has to be assigned to a variable first, for instance. It is possible to call such a property directly by enclosing it in parentheses.

Example #9 Calling an anonymous function stored in a property

class Foo
<
public $bar ;

public function __construct () <
$this -> bar = function() <
return 42 ;
>;
>
>

echo ( $obj -> bar )(), PHP_EOL ;

The above example will output:

extends

A class can inherit the constants, methods, and properties of another class by using the keyword extends in the class declaration. It is not possible to extend multiple classes; a class can only inherit from one base class.

The inherited constants, methods, and properties can be overridden by redeclaring them with the same name defined in the parent class. However, if the parent class has defined a method or constant as final, they may not be overridden. It is possible to access the overridden methods or static properties by referencing them with parent::.

Note: As of PHP 8.1.0, constants may be declared as final.

Example #10 Simple Class Inheritance

class ExtendClass extends SimpleClass
<
// Redefine the parent method
function displayVar ()
<
echo «Extending classn» ;
parent :: displayVar ();
>
>

$extended = new ExtendClass ();
$extended -> displayVar ();
?>

The above example will output:

Signature compatibility rules

When overriding a method, its signature must be compatible with the parent method. Otherwise, a fatal error is emitted, or, prior to PHP 8.0.0, an E_WARNING level error is generated. A signature is compatible if it respects the variance rules, makes a mandatory parameter optional, and if any new parameters are optional. This is known as the Liskov Substitution Principle, or LSP for short. The constructor, and private methods are exempt from these signature compatibility rules, and thus won’t emit a fatal error in case of a signature mismatch.

Example #11 Compatible child methods

class Base
<
public function foo ( int $a ) <
echo «Validn» ;
>
>

class Extend1 extends Base
<
function foo ( int $a = 5 )
<
parent :: foo ( $a );
>
>

class Extend2 extends Base
<
function foo ( int $a , $b = 5 )
<
parent :: foo ( $a );
>
>

$extended1 = new Extend1 ();
$extended1 -> foo ();
$extended2 = new Extend2 ();
$extended2 -> foo ( 1 );

The above example will output:

The following examples demonstrate that a child method which removes a parameter, or makes an optional parameter mandatory, is not compatible with the parent method.

Example #12 Fatal error when a child method removes a parameter

class Base
<
public function foo ( int $a = 5 ) <
echo «Validn» ;
>
>

class Extend extends Base
<
function foo ()
<
parent :: foo ( 1 );
>
>

Output of the above example in PHP 8 is similar to:

Example #13 Fatal error when a child method makes an optional parameter mandatory

class Base
<
public function foo ( int $a = 5 ) <
echo «Validn» ;
>
>

class Extend extends Base
<
function foo ( int $a )
<
parent :: foo ( $a );
>
>

Output of the above example in PHP 8 is similar to:

Renaming a method’s parameter in a child class is not a signature incompatibility. However, this is discouraged as it will result in a runtime Error if named arguments are used.

Example #14 Error when using named arguments and parameters were renamed in a child class

class A <
public function test ( $foo , $bar ) <>
>

class B extends A <
public function test ( $a , $b ) <>
>

// Pass parameters according to A::test() contract
$obj -> test ( foo : «foo» , bar : «bar» ); // ERROR!

The above example will output something similar to:

::class

The class keyword is also used for class name resolution. To obtain the fully qualified name of a class ClassName use ClassName::class . This is particularly useful with namespaced classes.

Example #15 Class name resolution

namespace NS <
class ClassName <
>

The above example will output:

The class name resolution using ::class is a compile time transformation. That means at the time the class name string is created no autoloading has happened yet. As a consequence, class names are expanded even if the class does not exist. No error is issued in that case.

Example #16 Missing class name resolution

The above example will output:

As of PHP 8.0.0, the ::class constant may also be used on objects. This resolution happens at runtime, not compile time. Its effect is the same as calling get_class() on the object.

Example #17 Object name resolution

The above example will output:

Nullsafe methods and properties

As of PHP 8.0.0, properties and methods may also be accessed with the «nullsafe» operator instead: ?-> . The nullsafe operator works the same as property or method access as above, except that if the object being dereferenced is null then null will be returned rather than an exception thrown. If the dereference is part of a chain, the rest of the chain is skipped.

The effect is similar to wrapping each access in an is_null() check first, but more compact.

Example #18 Nullsafe Operator

// As of PHP 8.0.0, this line:
$result = $repository ?-> getUser ( 5 )?-> name ;

// Is equivalent to the following code block:
if ( is_null ( $repository )) <
$result = null ;
> else <
$user = $repository -> getUser ( 5 );
if ( is_null ( $user )) <
$result = null ;
> else <
$result = $user -> name ;
>
>
?>

The nullsafe operator is best used when null is considered a valid and expected possible value for a property or method return. For indicating an error, a thrown exception is preferable.

User Contributed Notes 13 notes

I was confused at first about object assignment, because it’s not quite the same as normal assignment or assignment by reference. But I think I’ve figured out what’s going on.

First, think of variables in PHP as data slots. Each one is a name that points to a data slot that can hold a value that is one of the basic data types: a number, a string, a boolean, etc. When you create a reference, you are making a second name that points at the same data slot. When you assign one variable to another, you are copying the contents of one data slot to another data slot.

Now, the trick is that object instances are not like the basic data types. They cannot be held in the data slots directly. Instead, an object’s «handle» goes in the data slot. This is an identifier that points at one particular instance of an obect. So, the object handle, although not directly visible to the programmer, is one of the basic datatypes.

What makes this tricky is that when you take a variable which holds an object handle, and you assign it to another variable, that other variable gets a copy of the same object handle. This means that both variables can change the state of the same object instance. But they are not references, so if one of the variables is assigned a new value, it does not affect the other variable.

// Assignment of an object
Class Object <
public $foo = «bar» ;
>;

$objectVar = new Object ();
$reference =& $objectVar ;
$assignment = $objectVar

//
// $objectVar —>+———+
// |(handle1)—-+
// $reference —>+———+ |
// |
// +———+ |
// $assignment —>|(handle1)—-+
// +———+ |
// |
// v
// Object(1):foo=»bar»
//
?>

$assignment has a different data slot from $objectVar, but its data slot holds a handle to the same object. This makes it behave in some ways like a reference. If you use the variable $objectVar to change the state of the Object instance, those changes also show up under $assignment, because it is pointing at that same Object instance.

-> foo = «qux» ;
print_r ( $objectVar );
print_r ( $reference );
print_r ( $assignment );

//
// $objectVar —>+———+
// |(handle1)—-+
// $reference —>+———+ |
// |
// +———+ |
// $assignment —>|(handle1)—-+
// +———+ |
// |
// v
// Object(1):foo=»qux»
//
?>

But it is not exactly the same as a reference. If you null out $objectVar, you replace the handle in its data slot with NULL. This means that $reference, which points at the same data slot, will also be NULL. But $assignment, which is a different data slot, will still hold its copy of the handle to the Object instance, so it will not be NULL.

= null ;
print_r ( $objectVar );
print_r ( $reference );
print_r ( $assignment );

Источник

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal error cannot initialize render
  • Fatal error cannot init steam
  • Fatal error cannot find the specified resources dll как исправить
  • Fatal error cannot create temporary crash log file
  • Fatal error something went wrong facp

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии