This i my class:
<?php
namespace Classes;
class Setting
{
public static function siteAddress()
{
return 'https://text.com';
}
}
?>
In my template i use this method:
<?php
use \Classes\Setting;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="<?php echo Setting::siteAddress(); ?>/public/admin/asset/css/style.css" rel="stylesheet">
</head>
<body>
How I can access to siteAddress();
without include use \Classes\Setting;
?
Actually, if I want use siteAddress();
in every page, I shoud include use \Classes\Setting;
!
source https://stackoverflow.com/questions/67862825/php-access-variable-of-class-without-use
No comments:
Post a Comment