Loading multiple versions of the same class

前端 未结 3 1638
一整个雨季
一整个雨季 2020-12-17 01:05

Let\'s say I release a code library as a standalone PHP class. Someone then uses version 1.0 of that library in their application. Later, I release version 2.0 of the libr

3条回答
  •  [愿得一人]
    2020-12-17 01:33

    Let the user select a version, then according to that load your api file

    The file name should be dynamically determinable, for example:

    include('/lib/api-'.$versionId.'/library.php'); 
    

    if version -1.0 as wise

    Be careful to ensure that the user input is converted into a single decimal float and nothing nefarious.

提交回复
热议问题