A
A
Arthur Grand2015-10-08 19:53:26
PHP
Arthur Grand, 2015-10-08 19:53:26

What is the best way to organize methods?

Which of the following entries would be more convenient for you to use and why?

$request->get();
$request->get('id');
$request->get('id', 0);

$request->getAll();
$request->getRequired('id');
$request->get('id', 0);

return everything from $_GET return
$_GET['id'] or display an error
return $_GET['id'] or 0 already encountered

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2015-10-08
@saboteur_kiev

Read about programming styles. Read about variable and method naming conventions. Read what it's for.
It doesn't matter how long the code in the backend is, as long as it's easier to read. a couple of bytes back and forth, but if you postpone the project for a month and then you have to pick it up, you won’t remember what kind of get it is and what kind of get it is.

N
ndbn, 2015-10-09
@ndbn

The first option looks prettier, but, because. with different arguments, the function behaves differently, for example, it can display an error, I would bet on the second option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question