PHP Nested classes work… sort of?

后端 未结 3 1888
死守一世寂寞
死守一世寂寞 2020-12-10 06:21

So, if you try to do a nested class like this:

//nestedtest.php

class nestedTest{
    function test(){
         class E extends Exception{}
         throw n         


        
3条回答
  •  甜味超标
    2020-12-10 06:54

    The second way is not nesting of classes. You just have your both declarations in one file, which is different from your first example. In PHP you can have multiple class declarations in one file it is a organizational decision not a requirement.

提交回复
热议问题