search

Home  >  Q&A  >  body text

Why do you have to write it in a roundabout way using constants? Isn’t it better to write DSN directly?

Like the question, thank the teacher for the answer

꯭人꯭生꯭就꯭像꯭过꯭山꯭车꯭꯭人꯭生꯭就꯭像꯭过꯭山꯭车꯭1890 days ago999

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2019-12-21 20:02:57

    First of all, constants are super-global and do not need to be defined in multiple places, which reduces development costs

    Secondly, the main function of constants can avoid repeated definitions and tampering with their values. When team development or when the amount of code is large, when defining some data that you do not want to change. If you use global variables, if you accidentally use the same variable name in subsequent code, the previous variable value will be replaced, and the code running result will not be what we expect

    reply
    0
  • Cancelreply