Test Shariful OOP
unknown
php
3 years ago
505 B
3
Indexable
Never
<?php // Procedural function user_new() { return array( 'variables' => array() ); } function user_set($user, $name, $value) { $user['variables'][$name] = $value; return $user; } function user_get($user, $name) { $value = isset($user['variables'][$name]) ? $user['variables'][$name] : null; return array($user, $value); } $user = user_new(); $user = user_set($user, 'foo', 'hello'); list($user, $value) = user_get($user, 'foo'); // Convert above into OOP ?>