当前位置:网站首页>PHP import classes in namespace
PHP import classes in namespace
2022-06-13 03:14:00 【wks19891215】
A class declared in a namespace (space.php):
<?php
namespace mspace;
class mclass
{
public function __construct()
{
echo __METHOD__."\n";
}
}
?>
Here is in another file (use_space.php) Methods that use this class in :
<?php
require_once "./space.php";
// The first way to use it , Direct reference suffix
use \mspace\mclass;
$obj = new mclass();
// The second way to use it , Use the alias
use \mspace\mclass as mclass1;
$obj1 = new mclass1();
?>
In command line (php 5.5.36) Run in use_space.php, Output is :
mspace\mclass::__construct
mspace\mclass::__constructYou can see mclass The constructor and mclass equally , Because it's just an alias , Not a real class .
That is, the constructor gets the correct call .
边栏推荐
- On the career crisis of programmers at the age of 35
- Data Governance Series 1: data governance framework [interpretation and analysis]
- Brew tool - "fatal: could not resolve head to a revision" error resolution
- Exercise 8-3 rotate array right
- HEAP[xxx.exe]: Invalid address specified to RtlValidateHeap( 0xxxxxx, 0x000xx)
- Spark Foundation
- MySQL transactions and locks (V)
- Five old code farmers, program life review: peace of mind is not the place to go
- Querywrapper constructor method
- Vs Code modify default terminal_ Modify the default terminal opened by vs Code
猜你喜欢

MySQL index bottom layer (I)

六款国产飞机专用GPU产品通过鉴定审查

技术博客,经验分享宝典

Few-shot Unsupervised Domain Adaptation with Image-to-Class Sparse Similarity Encoding

Radio design and implementation in IVI system

Ijkplayer source code ---packetqueue

Installing the IK word breaker
![[JVM series 4] common JVM commands](/img/32/339bf8a2679ca37a285f345ab50f00.jpg)
[JVM series 4] common JVM commands

2021-08-30 distributed cluster

Prometheus node_exporter安装并注册为服务
随机推荐
Wechat applet switch style rewriting
Hash table: whether alien languages are sorted
【pytorch 記錄】pytorch的變量parameter、buffer。self.register_buffer()、self.register_parameter()
Prometheus node_ Exporter installs and registers as a service
Prometheus node_exporter安装并注册为服务
C simple understanding - generics
C simple understanding - overloaded operator
[synchronization function] version 2.0.16-19 has the update of synchronization function repair, but the problem has not been solved
Few-shot Unsupervised Domain Adaptation with Image-to-Class Sparse Similarity Encoding
Code d'initialisation de l'arbre binaire
Prometheus install and register services
English语法_频率副词
【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
How to write product requirements documents
二叉树初始化代码
MySQL index
DDL operation table
Stack information, GC statistics
Personal understanding of grammar sugar
Solution of Kitti data set unable to download