PHP ini files manipulation

I hear that alot, and i could not find one complete tutorial/example/source/something that can fill my needs when it comes to manipulating INI files.
So, this is where i open my heart and speak endlessly on how hard it is for me to share these secrets of mine, and how much i put into a solution….
After that said, lets see what can we do about the issue.

 

The problem

Well, its a known fact that in order to manipulate an INI file we have to overwrite every change made, and this might cost us with process time for a simple and small scripts.

More to it, the sections in the INI file do not help when we try to read and point to a single key.

 

INI Handler to the rescue

I created a small class that handles several issues of this and it works perfectly and steadilly…

With the iniHandler.class.php you will be able to :

  1. Create new section
  2. Create new configuration key to a particular section
  3. update keys values
  4. update multiple keys in one simple step
  5. delete key from file

Needless to say i tested this script and it works relatively fast and it throws exception when needed.

$iniHandler = new IniHandler("example.ini");

This is how we create an instance of the iniHandler. Notice that the constructor expects for an ini file path, full or relative to the script.

I will stop for a moment and tell you, that in the ZIP file attached there are examples for all important manipulations you can do with IniHandler, but i want just to walk through some crutial things .

First of all, we have to call the handler’s methods surrounded by try-catch phrases like so :

try{
  $iniHandler->SetIniSection($settings);
}catch(Exception $e){
  echo "<span style='color:red;font-weight:bold'>Error : ".$e->getMessage()."</span>";
}

This will handle the error if there are any.

Second, some of the methods require an array, which is the settings keys and values.

Usually, an INI file looks something like :

[section_name1]
key1=value1
key2=value2
[section_name2]
key1=value1
key2=value2
key3=value3

When we want to update a single key, we will call the setIniVal method, but in this INI example above, we have the key named key1 in both section_name1 and section_name2.

If you have same key name in different sections, you will have to use the SetIniSection, which will update the key only in the section passed in the call.

So, as you can see (If you downloaded the examples) that the IniHandler.class.php got you covered.

If you have any question, please do not be shy, i live for the challenge:)…

One more thing before i go, if you dont mind, show this fine article to your friends and family, maybe one of them will get me a job and i will stop writing BS online…

Thanks people, I was Ofer and you were great!

103 thoughts on “PHP ini files manipulation

    1. ofermisk Post author

      Keep on coming my dear friend, i am posting every week a unique and friendly PHP script for all who needs it…

      Reply
    1. ofermisk Post author

      Read on, dude, read on. I am writing about what you actualy need, not what you can learn from educational websites.. Read and see how you can generate more reliable PHP websites in half the time you spent so far

      Reply
  1. Kenye

    It’s a pity you don’t have a donate button! I’d without a doubt donate to this superb blog!
    I suppose for now i’ll settle for book-marking and adding your
    RSS feed to my Google account. I look forward to fresh updates and will share this blog with
    my Facebook group. Talk soon!…I will be happy if you visit my blog and say something http://twitter-guide-1.blogspot.com/

    Reply
  2. Niamh

    No matter if some one searches for his vital thing, therefore he/she wants to be available that in detail, therefore that thing is maintained over here.

    Reply
  3. Elliott Tomme

    You may unquestionably see your expertise while in the function you compose. The world hopes for much more passionate writers like you who’re not afraid to mention how they feel. All the time adhere to your heart.

    Reply
  4. Theodore Chars

    Hello there, just grew to become alert for your blog by Google, and uncovered that it is actually actually informative. I am gonna watch out for brussels. I’ll appreciate when you proceed this in potential. Lots of people will likely be benefited out of your creating. Cheers!

    Reply
  5. Rina Alby

    You can absolutely see your experience from the get the job done you write. The world hopes for much more passionate writers which include you who are not afraid to mention how they believe. All the time adhere to your heart.

    Reply
  6. Gavin Stright

    You may absolutely see your knowledge in the get the job done you publish. The entire world hopes for all the more passionate writers for example you who’re not afraid to mention how they feel. All the time stick to your heart.

    Reply
  7. candy crush saga hack

    You actually make it seem so easy with your presentation
    but I find this topic to be really something which I think I would never understand.
    It seems too complex and very broad for me. I am looking forward for your next post,
    I will try to get the hang of it!

    Reply
  8. 79GregoryI

    Hi, it’s hard to find ofermisk.com in google, i found it on 25 spot, you should build some high quality backlinks, i know what can help you, just search in google for – edaya traffic increase

    Reply
  9. Nadine

    Heya i am for the first time here. I came across this board and I find It truly
    useful & it helped me out much. I hope to give something back and aid others
    like you aided me.

    Reply
  10. best muscle building supplements

    My developer is trying to convince me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using WordPress on a number of websites for about a year and am concerned about switching to another platform. I have heard good things about blogengine.net. Is there a way I can import all my wordpress content into it? Any kind of help would be greatly appreciated!

    Reply
  11. cures for hemroids

    I absolutely love your blog.. Very nice colors & theme. Did you build this site yourself? Please reply back as I’m wanting to create my own personal blog and would love to know where you got this from or just what the theme is named. Thank you!

    Reply
  12. Mckenzie Tecson

    I don’t even know how I finished up right here, but I thought this post was once great. I do not realize who you’re but definitely you’re going to a famous blogger if you happen to aren’t already. Cheers!|

    Reply
  13. zabor ilenta

    obviously like your web site however you need to check the spelling on several of your posts. Several of them are rife with spelling issues and I to find it very bothersome to tell the truth on the other hand I will surely come again again.

    Reply
  14. terinjak

    What’s up to every body, it’s my first pay a quick visit of this webpage; this website includes amazing and really good material in support of readers.

    Reply
  15. homeschool resources

    Hey there would you mind stating which blog platform you’re using? I’m going to start my own blog soon but I’m having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique. P.S Apologies for getting off-topic but I had to ask!

    Reply
  16. Tyson F. Gautreaux

    I just want to tell you that I am all new to blogs and really liked your page. Very likely I’m want to bookmark your website . You actually come with tremendous articles and reviews. Bless you for revealing your website.

    Reply
  17. buy quality backlinks

    Thanks , I have recently been searching for info about this topic for ages and yours is the best I’ve found out till now. But, what concerning the bottom line? Are you sure about the source?

    Reply
  18. Joshua Portee

    I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

    Reply
  19. Carroll B. Merriman

    I just want to say I am very new to blogs and truly liked you’re web blog. Most likely I’m planning to bookmark your website . You absolutely have tremendous well written articles. Thanks a bunch for sharing with us your web page.

    Reply
  20. coconut oil uses cooking

    So I checked the “Notify me when new comments are added” box, but ‘m getting a
    ton of e-mails now. Every time somebody writes a remark I get three emails.
    Is it possible to please look into this? Thanks a bunch!

    Reply
  21. Pingback: Bobsweep Review

  22. Pingback: URL

  23. Major Cadice

    Greetings! Self-same cooperative counsel within this post! It is the insufficiently changes that fabricate the mainly significant changes. Thankfulness for sharing!

    Reply
  24. Pingback: Cutie koz kids cute

  25. Depression and Anxiety

    Thanks for your whole work on this web page. My aunt enjoys making time for investigation and it’s really easy to understand why. Almost all learn all of the dynamic ways you give both interesting and useful techniques through the web blog and as well recommend contribution from website visitors on this point then my simple princess is in fact discovering a lot of things. Have fun with the rest of the year. You’re the one conducting a remarkable job.

    Reply
  26. Pingback: stainless steel chipboard screw supplier

  27. teak furniture

    I’m not sure where you’re getting your info, but good topic. I needs to spend some time learning more or understanding more. Thanks for great info I was looking for this info for my mission.

    Reply
  28. Pingback: Production Video fort collins

  29. cheap car parts

    Hey, you used to write great, but the last several posts have been kinda boring¡K I miss your tremendous writings. Past few posts are just a little bit out of track! come on!

    Reply
  30. blog templates

    Hi, i think that i saw you visited my blog thus i came to “return the favor”.I’m attempting to find things to enhance my web site!I suppose its ok to use some of your ideas!!

    Reply
  31. weight loss

    I haven¡¦t checked in here for a while as I thought it was getting boring, but the last several posts are great quality so I guess I¡¦ll add you back to my everyday bloglist. You deserve it my friend 🙂

    Reply
  32. windows phone

    whoah this blog is excellent i really like reading your articles. Stay up the good paintings! You realize, lots of individuals are looking around for this info, you can help them greatly.

    Reply
  33. google sniper scam

    Hello, you used to write excellent, but the last several posts have been kinda boring… I miss your great writings. Past several posts are just a little bit out of track! come on!

    Reply
  34. floor plans

    I have not checked in here for some time as I thought it was getting boring, but the last few posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂

    Reply
  35. famous quotes about leadership

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thank you!

    Reply
  36. Abel Feraco

    Wow, marvelous blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is excellent, as well as the content!

    Reply
  37. auto financing

    obviously like your web-site but you need to check the spelling on several of your posts. A number of them are rife with spelling issues and I to find it very troublesome to inform the truth on the other hand I will certainly come again again.

    Reply
  38. Stan Blau

    Thank you for the sensible critique. Me & my neighbor were just preparing to do a little research on this. We got a grab a book from our area library but I think I learned more clear from this post. I am very glad to see such excellent info being shared freely out there.

    Reply
  39. interior house designs

    Someone necessarily help to make seriously posts I’d state. This is the first time I frequented your website page and to this point? I surprised with the research you made to make this actual post incredible. Excellent task!

    Reply
  40. bespoke kitchens

    Good day very cool web site!! Man .. Beautiful .. Amazing .. I’ll bookmark your web site and take the feeds also¡KI’m glad to find so many useful info here in the publish, we’d like work out extra techniques in this regard, thanks for sharing. . . . . .

    Reply
  41. Pingback: big krit type beat

  42. top eleven free tokens

    Great post. I used to be checking continuously this
    weblog and I’m impressed! Very useful info specifically the
    ultimate section 🙂 I take care of such info much.
    I used to be looking for this certain information for a very long time.
    Thanks and best of luck.

    Reply
  43. game of war fire age hack

    Hi there, just became alert to your blog through Google, and found that
    it’s truly informative. I am gonna watch out for brussels.
    I will appreciate if you continue this in future.
    A lot of people will be benefited from your writing.
    Cheers!

    Reply
  44. porno izle

    Thanks for every other informative blog. Where else may just I get that type of info written in such
    a perfect manner? I have a undertaking that I am just
    now operating on, and I have been at the look out for such information.

    Reply
    1. ofermisk Post author

      There are many PHP blogs online, and although i would love to see you more often in here, you can find them on Google.
      For beginner courses and tutorials you can go to w3schools.
      Best of luck and share this if you liked my writing…

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


*