我正在研究自动加载。我找到了这行代码,其中trim和str_replace做同样的事情,摆脱了反斜杠(在我的未知中)。
但我不明白为什么他们需要这样做?
有人可以解释一下吗?
var sphere = new THREE.SphereGeometry(200, 100, 100);
//Skipping unrelated code and to include creating sphere mesh and adding it to the scene
var curve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(xStart, yStart, zStart),
new THREE.Vector3((xStart+xEnd)/2 + xOffset, (yStart+yEnd)/2 + yOffset, (zStart+zEnd)/2 + zOffset), //Midpoint with offset
new THREE.Vector3(xEnd, yEnd, zEnd)
);
var geometry = new THREE.Geometry();
geometry.vertices = curve.getPoints( 50 );
var line = new THREE.Line(geometry, materialLine);
globe.scene.add(line);
答案 0 :(得分:0)
trim
删除字符串开头的反斜杠
然后str_replace
用常量DIRECTORY_SEPARATOR
替换所有其他反斜杠。
为了论证,我们说DIRECTORY SEPARATOR
是/
。
$class = '\One\Ting\ming'; \\ notice that I have added a leading backslash
strtolower(str_replace("\\", DIRECTORY_SEPARATOR, trim($class, "\\"))).".php";
修剪前导反斜杠后,变为
strtolower(str_replace("\\", DIRECTORY_SEPARATOR, "One\Ting\ming")).".php";
然后将所有\
更改为/
,它变为
strtolower("One/Ting/ming").".php";
最后,将字符串更改为全部小写并附加文件扩展名,它变为
"one/ting/ming.php";