Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #22870
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Newsgroups | it.comp.www.php |
| Subject | valore restituito al posto modificare il valore della variabile |
| Date | 2020-10-16 13:03 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <rmbums$4ar$1@gioia.aioe.org> (permalink) |
// DESIGN 1
echo "Non funziona, ma mi piace il 'DESIGN 1' ";
$arr = [1, 2];
print_r(
array_shift($arr)
);
// DESIGN 2
echo "Funziona, ma non mi piace il 'DESIGN 2': ";
$arr = [1, 2];
array_shift($arr);
print_r(
$arr
);
Output:
Non funziona, ma mi piace il 'DESIGN 1': 1
Funziona, ma non mi piace il 'DESIGN 2': Array
(
[0] => 2
)
Per trovare un compromesso mi son creato questa classe:
<?php
class FirstProcessedArgumentReturn {
static function __callStatic(string $name, array $arguments) {
$name($arguments);
return $arguments[0];
}
}
FirstProcessedArgumentReturn::array_shift([1, 2]);
//TODO: Test the method FirstProcessedArgumentReturn::array_push(...);
//TODO: Test the method FirstProcessedArgumentReturn::array_pop(...);
//TODO: Test the method ...
PHP Notice: Undefined offset: 0 in /tmp/test.php on line 6
Ma come vedete qualcosa non funziona: il motivo lo lascio immaginare.
Qualche idea?
Back to it.comp.www.php | Previous | Next — Next in thread | Find similar | Unroll thread
valore restituito al posto modificare il valore della variabile alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-10-16 13:03 +0200
Re: valore restituito al posto modificare il valore della variabile alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-10-16 13:19 +0200
Re: valore restituito al posto modificare il valore della variabile massiws <m.simonini@gmail.com> - 2023-07-20 20:48 -0700
csiph-web