Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Clearing things up

Comments in 'Plugin Development' started by FlamingGenius, Sep 27, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I took a couse by sololearn(ios app) on PHP now ive done a little studying and i feel like i have this right but i wanna make sure

    this is how u create a config

    PHP:
    $config $this->config = new config("config.yml");
    And to get a config
    PHP:
    $this->config->getConfig("config.yml");
    Please correct me if im wrong
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Incorrect. Please refer to JoinCommands and look at the code, I think it'd be simple enough for a beginner to understand. ;) It should be $config = $this->getConfig(), not $config = $this->config = $this->getConfig(). For the second one, it should just be $this->getConfig() and not $this->config->getConfig("config.yml").
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Okay So to create a config named config.yml all i have to do is
    PHP:
    $this->saveDefaultConfig();
    And to get data from the config U just do
    PHP:
    $this->getConfig->get("key") === value;
    Also is it neccesary to user
    PHP:
     ===
    ? Can u just use
    PHP:
     ==
    just curious because using 3 feels like an extremity to me i just prefer to say equal to not identical to
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Yes, yes(depending on circumstances), no, and sure, why not. Just look here: http://php.net/manual/en/language.operators.comparison.php
  5. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Just look at the link I gave you it gives detailed descriptions for everything.
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It is very different. If you have 2 strings (Ex: "#Roasted" and "#Roasted") using either is ok.
    PHP:
    if("#Roasted" ==  "#Roasted")

    if(
    "#Roasted" ===  "#Roasted")
    But if you compare an integer and a string (Ex: 1 and "1") == would return true but === would return false.
    Why? == means Equal and === means Identical.
    When you use equal, maybe they are different types but PHP would do something called Type Juggling.
    Identical: DID YOU PASS 2nd GRADE MATH???
    PEMapModder and jojoe77777 like this.

Share This Page

Advertisement