3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name='2class'; $className = ltrim($name, '\\'); if ($lastNsPos = strrpos($className, '\\')) { /*имеется namespace, значит vendor*/ $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1) . '.class.php'; $fileName = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR; $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; //TODO Дописать правильное составление полного пути с учетом modules и vendor // Во избежание проблем с путями указывать относительный путь от этого файла. // Т.е. __DIR__/../ для modules и соответствующий для vendor } else { $fileName = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ; //TODO Если _ нет, то имя папки должно соответствовать имени класса и работает только для modules $className = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.class.php'; } $fileName .= $className; print($fileName);
Output for git.master, git.master_jit, rfc.property-hooks
/in/../2class.class.php

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.86 ms | 401 KiB | 8 Q