php-basic

PHP : What is the better way to access object inside an array then what i got now ?

$jj_post is the array output debug via print_r. this variable is an array of object Array ( [0] => stdClass Object ( [ID] => 2571 ) ) i access the object property, ID, via code like this : $jj_post_id = $jj_post[0]; $jj_ID = $jj_post_id->ID; so, is there a better way, cause this is the only t...

Isset and PHP Global Variable

i have doubt on this particular problem : Global variabe initiation. i got this code and has global variable named conditional_random here : function hello_testing() { global $conditional_random; if (isset($conditional_random)) { echo "foo is inside"; } } As it's name, the global variable (conditional_random) can be or...

Does this function have too many parameters?

In the end, I got this function. I don't know whether it's normal or not. function user_registration($user_name, $user_email , $user_pass , $address , $city , $postalcode , $country , $phone , $mobilephone) How and why can I improve this? ...

PHP : How to Get object or class name

right now, i have this code where $obj_arr maybe contain array and object. $obj_temp = array ($obj_identity, $arr_user, $obj_locale, $arr_query); foreach ($obj_temp as $maybe_arr) { if (is_array($maybe_arr)) : $name = (string) key($maybe_arr); if (is_object($maybe_arr)) : ...

how i got the name of the string variable in the strange attempt to debug unknown variable ?

i got several variable. One is variable string, object, and array. $mystring = "hello im input"; $myobject = new userclass; $myarray = array ( 0 => 'zero', 1 => "one"); i want to create a new array with its variable name as key before send it to as function parameter with it's first line use extract function. the multi_array will ...