【发布时间】:2012-08-25 13:08:05
【问题描述】:
我正在创建一个简单的 PHP 应用程序,我想使用 YAML 文件作为数据存储。我将以关联数组的形式获取数据,例如:
$user = array('username' => 'martin', 'md5password' => '5d41402abc4b2a76b9719d911017c592')
但是,我想用一些函数扩展关联数组并使用-> 运算符,所以我可以这样写:
$user->username = 'martin'; // sets $user['username']
$user->setPassword('hello'); // writes md5 of 'hello' to $user['md5password']
$user->save(); // saves the data back to the file
在没有类定义的情况下,有没有一种好方法可以做到这一点?
基本上,我想在 PHP 中使用 JavaScript 样式对象 :)
【问题讨论】:
-
这些天至少应该使用 sha1。
-
+wesside 2016 更新:BCrypt 通过 password_hash 或带有 SHA512 的 PBKDF2。
-
@mjsa 看看!
标签: php class object yaml associative-array