How to understand someone else’s PHP code?

There are php files as separate parts of the site. Where can I find out how, how to combine them into a single site, if I myself had nothing to do with writing the site? Everything will do: books, articles, etc.


Answer 1, authority 100%

Learn PHP from books (and not from someone else’s code), when the knowledge base is large, then by itself you will learn to understand someone else’s code.


Answer 2

You need to look at specific php scripts. If they have a call to a specific server (to the one where the file was stolen from), then you need to replace these calls with the address of your server. If the script works “on its own”, then you can simply upload it to your site’s FTP server. If the script uses some resources of the server on which it is located (for example, it opens the image /images/image.png), then you need to find or create these resources and upload them to the appropriate folder (i.e., in this example, create in the directory with the php script, the images directory and fill it with image.png), but again, look at the script itself. If the script is associated with other scripts from this site, then they also need to be downloaded and uploaded to your server. And, of course, you need to review all scripts and change specific data (for example, site name, copyright, etc.).
Well, in general, in order to “understand someone else’s code” (that is, to understand what and how this code does), you first need to know the language of this code, in this case PHP.


Answer 3

Usually turned on the display of errors, including notice, and fixed them all. Suitable for simple and medium engines, as a rule, self-handwritten. Complex ones (such as IPB, drupal) usually have documentation.

Use advanced IDEs, they will help you figure out where everything comes from.

Look for exit points and carefully “unwind” from them in the opposite direction. Pay attention to constructions like
$$varname….
$funcname()….
compact()….
list()….
global….
__get()/__set()….
They can make life much more difficult.

Well, yes, knowledge of PHP is required, you can’t take that away. =)