具体的想要实现的效果也和图上描述的差不多,我想问下在TP3.2中如何设置命名空间可以实现图上描述的功能!谢谢!
7 个解决方案
#1
namespace Common\Common\Function/Music
你放错地方了
Common\Common 目录下专放函数用的。
你那个类可以Common\目录下新建一个目录放例如
Common\Common #函数目录
Common\Tool #工具类目录
Common\Tool\Music.class.php
Common\Tool\tt.class.php
命名空间
Common\Tool\Music.class.php
#命名空间就是
namespace Common\Tool\Music;
#调用
use Common\Tool\Music;
#2
namespace Common\Common\Function/Music
改为
namespace Common\Common\Function\Music
斜杠打错了
#3
你还是好好看看文档吧!估计你没看!
#4
谢谢了~非常感谢!!!!
#5
非常感谢~
#6
最近在学PHP 也遇到同样的问题,按照楼下的做了,还是不能,请教楼主如何解决啊
#7
<?php
namespace Permission\Common;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017-05-15
* Time: 10:06
* Ref: Application/Permission/Common/Hash.class.php
*/
class Hash {
/**
* @param string $algo The algorithm (sha256, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) )
*/
public static function create($algo, $data, $salt) {
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
}
\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),
namespace Permission\Common;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017-05-15
* Time: 10:06
* Ref: Application/Permission/Common/Hash.class.php
*/
class Hash {
/**
* @param string $algo The algorithm (sha256, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) )
*/
public static function create($algo, $data, $salt) {
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
}
\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),
#1
namespace Common\Common\Function/Music
你放错地方了
Common\Common 目录下专放函数用的。
你那个类可以Common\目录下新建一个目录放例如
Common\Common #函数目录
Common\Tool #工具类目录
Common\Tool\Music.class.php
Common\Tool\tt.class.php
命名空间
Common\Tool\Music.class.php
#命名空间就是
namespace Common\Tool\Music;
#调用
use Common\Tool\Music;
#2
namespace Common\Common\Function/Music
改为
namespace Common\Common\Function\Music
斜杠打错了
#3
你还是好好看看文档吧!估计你没看!
#4
谢谢了~非常感谢!!!!
#5
非常感谢~
#6
最近在学PHP 也遇到同样的问题,按照楼下的做了,还是不能,请教楼主如何解决啊
#7
<?php
namespace Permission\Common;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017-05-15
* Time: 10:06
* Ref: Application/Permission/Common/Hash.class.php
*/
class Hash {
/**
* @param string $algo The algorithm (sha256, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) )
*/
public static function create($algo, $data, $salt) {
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
}
\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),
namespace Permission\Common;
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017-05-15
* Time: 10:06
* Ref: Application/Permission/Common/Hash.class.php
*/
class Hash {
/**
* @param string $algo The algorithm (sha256, sha1, whirlpool, etc)
* @param string $data The data to encode
* @param string $salt The salt (This should be the same throughout the system probably)
* @return string The hashed/salted data ( C(HASH_PASSWORD_KEY) )
*/
public static function create($algo, $data, $salt) {
$context = hash_init($algo, HASH_HMAC, $salt);
hash_update($context, $data);
return hash_final($context);
}
}
\Permission\Common\Hash::create('sha1', $pwd, C('HASH_PASSWORD_KEY')),