ABSPATH or __FILE__?

前端 未结 4 1468
长情又很酷
长情又很酷 2020-12-24 14:42

Can someone tell me if either of these two methods has an advantage over the other and why?

$mydir = ABSPATH.\'/wp-content/themes/mytheme/images\';

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 15:03

    For my own projects I would choose dirname(__FILE__), also there is a new constant in PHP:

    __DIR__ === dirname(__FILE__)
    

提交回复
热议问题