goma smile Posted September 25, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2015 Report Share Posted September 25, 2015 556 posti šeit, un vēl šādas muļķības dari :( Quote Link to comment Share on other sites More sharing options...
jurchiks Posted September 25, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
xPtv45z Posted September 25, 2015 Report Share Posted September 25, 2015 private static function getValue(&$var) { return isset($var) ? $var : NULL; } $kkas = self::getValue($value['kautkas']); Quote Link to comment Share on other sites More sharing options...
goma smile Posted September 25, 2015 Author Report Share Posted September 25, 2015 Paldies biedri Quote Link to comment Share on other sites More sharing options...
goma smile Posted September 25, 2015 Author Report Share 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 Link to comment Share on other sites More sharing options...
jurchiks Posted September 25, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
nemakuphp Posted September 25, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
codez Posted September 25, 2015 Report Share Posted September 25, 2015 jurchiks nezin, kas ir references. http://php.net/manual/en/language.references.pass.php Quote Link to comment Share on other sites More sharing options...
jurchiks Posted September 25, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
Kavacky Posted September 26, 2015 Report Share Posted September 26, 2015 Ok, that's new...Oh, here's that new thing called "memory". Quote Link to comment Share on other sites More sharing options...
jurchiks Posted September 26, 2015 Report Share Posted September 26, 2015 I'm not talking about references, I'm talking about passing a reference to an UNDEFINED variable. Quote Link to comment Share on other sites More sharing options...
Kasspars Posted September 26, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
jurchiks Posted September 27, 2015 Report Share Posted September 27, 2015 Tu pats šitādu prikolu zināji? Tikai godīgi. Quote Link to comment Share on other sites More sharing options...
Леший Posted September 28, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
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.