简单地说:
__FILE__ 返回当前 路径+文件名
dirname(__FILE__) 返回当前文件路径的 路径部分 (后面没有“\”号)
dirname(dirname(__FILE__));得到的是文件上一层目录名(不含最后一个“\”号)
<?php
$path = __FILE__;
echo $path;
echo '<br/>';
$path_1 = __DIR__;
echo $path_1;
echo '<br/>';
$path_2 = dirname(__FILE__);
echo $path_2;
echo '<br/>';
$path_3 = dirname(dirname(__FILE__));
echo $path_3;
?>
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVgAAABfCAIAAAAifEgbAAAKbElEQVR4nO2cXaLqIAyE3VFX5ILcjYtxP70PWkuSmQD98Vx0vrdzLAHSMkBacpmFED/P5a8bIIT4eyQEQggJgRBCQiCEmCUEQohZQiCEmCUEQohZQiCEmCUEw3G/Xi6X6327gcdtulym2+O4Jv0X7PbLufz3XgdC8LhNF4ftwf2K+/S4TehemMuj8cLSPgPPX3zx+zW0v3pXljpCU2zBtC/Pig21x/Rl73kZc3LlgScupH04Ctbc7JdNxjf65a8ZVgjSNj9uE7qgeRwXZc043WkANfw1HI3RagffI9xfBISA9aX7yXzcpul6XR1AnFwxW6/1pEeSNPeI6qLX+/3y13ynEJARu2Ucmzu41wD+7Xq9WqvVZ+ZpZ5qCFORCYC33PZmP23S53k0Z7I3/VQjYzTtcCLb55a/5JiEol97wZmwbx0WpYwy4Ofp6d3NI+1gJ24qaEJQd6HkynzLgy0B3vC4ptyXFEgLvRIpdyqtklC+8Cwylk3/G5rrd0Wq6/CEu1sqrkYlOv6DWFD/Fgt4FRcHpds9Gx3R7kAaYRypUs9x3/OtH2CgEyxiLF2ya0F//2G0AjKTr3a0m67voog4nBS0rAtyUWnXFY+8eUvw4s8BIqNVd4IrD2dabKwbw7d3M8E/c3Mqyyfxh78zjdrtnJnb4Jf5BC1bc5/pZ/mRd58NOYBtZ/IrDXafSFCyE6hSjNhvGse3xbgPxwZr8k9ugA6aOGMRobIqby2iVpUqFYRydHFYptgySEjBNl87gux+iZVziQCQPBlL8VE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