goma smile Posted September 25, 2015 Report Posted September 25, 2015 (edited) ir kaut kas tāds private function ifExist($k){ return (isset($k) ? $k : NULL); } un tad kad arraya notiek $kkas = $this->ifExist($value['kautkas']); izmetās errors undeffined index vai kkas tāds nu tas kas parasti arraya izmetās ka tāda nav... bet ja izmanto $kkas = (isset($value['kautkas']) ? $value['kautkas'] : NULL); tad viss iet... Kas varētu būt pa vainu... ? Edited September 25, 2015 by goma smile Quote
briedis Posted September 25, 2015 Report Posted September 25, 2015 556 posti šeit, un vēl šādas muļķības dari :( Quote
jurchiks Posted September 25, 2015 Report Posted September 25, 2015 No sākuma gribēju iepostot tikai triple facepalm bildīti, bet apdomājos: private static function getValue($arr, $k) { return (isset($arr[$k]) ? $arr[$k] : NULL); } $kkas = self::getValue($value, 'kautkas'); Quote
xPtv45z Posted September 25, 2015 Report Posted September 25, 2015 private static function getValue(&$var) { return isset($var) ? $var : NULL; } $kkas = self::getValue($value['kautkas']); Quote
goma smile Posted September 25, 2015 Author Report Posted September 25, 2015 private static function getValue(&$var) { return isset($var) ? $var : NULL; } $kkas = self::getValue($value['kautkas']); vēlviens jautājums varētu lūdzu īsi un latviski paskaidrot ko nozīmē/dod šīs &$var "&" Quote
jurchiks Posted September 25, 2015 Report Posted September 25, 2015 (edited) @xPtv45z - ko tu tur huiņu postē? Tu saproti atšķirību starp savu kodu un manējo? Tavs kods metīs to pašu kļūdu, kas viņam jau ir. Edited September 25, 2015 by jurchiks Quote
nemakuphp Posted September 25, 2015 Report Posted September 25, 2015 @xPtv45z - ko tu tur huiņu postē? Tu saproti atšķirību starp savu kodu un manējo? Tavs kods metīs to pašu kļūdu, kas viņam jau ir. https://eval.in/private/6215d41307908fNeizskatās, ka mestu Quote
codez Posted September 25, 2015 Report Posted September 25, 2015 jurchiks nezin, kas ir references. http://php.net/manual/en/language.references.pass.php Quote
jurchiks Posted September 25, 2015 Report Posted September 25, 2015 (edited) Ok, that's new... Bet tāds kods nav intuitīvs. Tu padod kaut ko funkcijai un funkcijā pārbaudi, vai kaut kas vispār eksistē. Tas nav loģiski. Edited September 25, 2015 by jurchiks Quote
Kavacky Posted September 26, 2015 Report Posted September 26, 2015 Ok, that's new...Oh, here's that new thing called "memory". Quote
jurchiks Posted September 26, 2015 Report Posted September 26, 2015 I'm not talking about references, I'm talking about passing a reference to an UNDEFINED variable. Quote
Kasspars Posted September 26, 2015 Report Posted September 26, 2015 jurchik tu esi reality warping speciālists! Es zinu, kas ir ūdens bet nezināju, ka tas ir slapjšs. Kaut kā tā Quote
jurchiks Posted September 27, 2015 Report Posted September 27, 2015 Tu pats šitādu prikolu zināji? Tikai godīgi. Quote
Леший Posted September 28, 2015 Report Posted September 28, 2015 Es zinu maz programmētāju ar pieredzi 2+ gadi, kas nezinātu, kas ir references. Btw, funkciju var optimizēt :D function getValue (&$var) { return $var; } https://eval.in/440512 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.