Я пытаюсь использовать RuntimeException
http://www.php.net/manual/en/class.runtimeexception.php
У меня есть эти файлы в той же папке:
Другие функции.php
<?php
namespace Pack\sp;
$Tble = NULL;
function SetTble($tble) {
global $Tble;
$Tble = $tble;
}
function GetTble() {
global $Tble;
return $Tble;
}
function Funct0($Str0, $Str1) {
return $Str0 == $Str1;
}
function Funct1($Arg) {
return "The Value is ".$Arg;
}
//... from 0 to 16
function Funct16($Arg) {
return "The Value is ".$Arg;
}
?>
Как вызвать все функции, содержащиеся в этом файле?
В одном файле класса SubClass.php у меня есть это:
<?php
namespace Pack\sp;
class SubClass {
public $CArg = "";
function FnClass($Arg) {
return "FnClass:The Value is from SubClass".$Arg;
}
}
?>
В другом файле класса LeadClass.php у меня есть это:
<?php
namespace Pack\sp;
require_once("OtherFunctions.php");
require_once("SubClass.php");
class LeadClass {
public function __construct($Name) {
echo("_._<br>");
$NewSC = new SubClass();
$NewSC->CArg = $Name;
SetTble($Name);
echo("ini:GetTble():".GetTble().":end<br>");
echo("ini:".$NewSC->FnClass($Name).":end<br>");
}
public function getName() {
throw new RuntimeException("Error Ever !<br>");
}
}
?>
Использование всего кода CallerNS.php
<?php
namespace Pack\sp;
require_once("LeadClass.php");
require_once("OtherFunctions.php");
$NewSC = new LeadClass("first");
$NewSC->getName();
if (Funct0("strings", "strings")) {
print("same strings<br>");
}
?>
Вот моя ошибка:
Неустранимая ошибка: класс Pack\sp\RuntimeException не найден в C:...\LeadClass.php в строке 15
В другой версии CallerNS.php
<?php
use Pack\sp;
require_once("LeadClass.php");
require_once("OtherFunctions.php");
if (Funct0("strings", "strings")) {
print("same strings<br>");
}
$NewSC = new LeadClass("first");
$NewSC->getName();
?>
Сообщение об ошибке:
Неустранимая ошибка: вызов неопределенной функции Funct0() в C:...\CallerNS.php в строке 5