Can you use static constants in PHP?

后端 未结 6 1059
面向向阳花
面向向阳花 2021-02-01 12:55

I expected the following to work but it doesn\'t seem to.



        
6条回答
  •  南笙
    南笙 (楼主)
    2021-02-01 13:19

    They're not static constants, just constants

    class Patterns 
    { 
        const EMAIL = "/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix"; 
        const INT = "/^\d+$/"; 
        const USERNAME = "/^\w+$/"; 
    } 
    
    echo Patterns::EMAIL;
    

提交回复
热议问题