S
S
sorry_i_noob2018-02-28 02:44:24
PHP
sorry_i_noob, 2018-02-28 02:44:24

Php - Is it bad if I have places where the path (string with the path) is repeated? For example "files/images/"? Or is it ok?

Should I put this in a separate function (in the model - I have MVC - get_path_images(), for example)? Or leave it like this - many places (classes) where the same line is repeated to indicate the path?
And further. Here I, for example, scored in the function getting a string with a path. And in other places I have the code repeated, where the line with the path + one more line (one directory) is used. But only one. Do I also need to create another function? For example, the first function returns:
files/images/
And then there are places where this path is used:
files/images/128x128/ Should
I also create a function for this? Only one directory has been added.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2018-02-28
@sorry_i_noob

It's generally bad when there is text inside the logic code!
All paths (and settings) must be in the variable store and they must all be unique.
If paths are made up of several variables through their concatenation ($a.$b. etc.) - a hierarchical "tree" must be formed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question