My Ini Design: Introduction: Difference between revisions
Jump to navigation
Jump to search
no edit summary
(New page: {{Nav My Ini Design}} PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files. If there is I could not find them h...) |
Upazixorys (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
=[http://itygeligub.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]= | |||
{{Nav My Ini Design}} | {{Nav My Ini Design}} | ||
PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files. | PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files. | ||
Line 17: | Line 18: | ||
=== my_ini_set === | === my_ini_set === | ||
'''''Description'':''' Sets the value of the given configuration option within the specified block. | '''''Description'':''' Sets the value of the given configuration option within the specified block. | ||
<pre> | |||
my_ini_set ( string $file, string $block, string $optionname , string $newvalue ) | my_ini_set ( string $file, string $block, string $optionname , string $newvalue ) | ||
</pre> | |||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
=== my_ini_get === | === my_ini_get === | ||
'''''Description'':''' Returns the value of the configuration option within the specified block on success. | '''''Description'':''' Returns the value of the configuration option within the specified block on success. | ||
<pre> | |||
my_ini_get (string $file, string $block, string $optionname ) | my_ini_get (string $file, string $block, string $optionname ) | ||
</pre> | |||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
Line 33: | Line 34: | ||
PHP has two really neat functions that perform this task with ease: | PHP has two really neat functions that perform this task with ease: | ||
{|cellpadding= | {|cellpadding="5" | ||
|-valign= | |-valign="top" | ||
|'''$array=file($file)'''||This reads every line from named file $file and saves each line as an element in the array $array | |'''$array=file($file)'''||This reads every line from named file $file and saves each line as an element in the array $array | ||
|-valign= | |-valign="top" | ||
|'''file_put_contents($file,$array)'''||This writes the entire contents of array $array into file $file. | |'''file_put_contents($file,$array)'''||This writes the entire contents of array $array into file $file. | ||
|} | |} | ||
Line 47: | Line 48: | ||
Create a new folder named test and the following files with content as shown below | Create a new folder named test and the following files with content as shown below | ||
{| | {| | ||
|-valign= | |-valign="top" | ||
| | | | ||
UniServer\plugins\test\'''Run_test.bat''' | UniServer\plugins\test\'''Run_test.bat''' | ||
<pre> | |||
COLOR B0 | COLOR B0 | ||
@echo off | @echo off | ||
Line 56: | Line 57: | ||
..\..\usr\local\php\php.exe test.php | ..\..\usr\local\php\php.exe test.php | ||
pause | pause | ||
</pre> | |||
UniServer\plugins\test\'''test.php''' | UniServer\plugins\test\'''test.php''' | ||
<pre> | |||
<?php | |||
$ini_array = file( | $ini_array = file("cron.ini"); | ||
file_put_contents( | file_put_contents("out_cron.txt",$ini_array); | ||
? | ?> | ||
</pre> | |||
UniServer\plugins\test\'''cron.ini''' | UniServer\plugins\test\'''cron.ini''' | ||
<pre> | |||
; Test example file for cron timers | ; Test example file for cron timers | ||
; Period values hourly, daily or weekly | ; Period values hourly, daily or weekly | ||
Line 83: | Line 84: | ||
period = hourly | period = hourly | ||
ref = | ref = | ||
</pre> | |||
| | | | ||
| &nbsp; | ||
| | | | ||
'''''Run_test.bat'':''' | '''''Run_test.bat'':''' | ||
Line 142: | Line 143: | ||
{| | {| | ||
|-valign= | |-valign="top" | ||
| | | | ||
However to manipulate the content of an array we need access to its keys and values. | However to manipulate the content of an array we need access to its keys and values. | ||
Line 158: | Line 159: | ||
'''''Note'':''' A key points to a location of an element (value) within an array. | '''''Note'':''' A key points to a location of an element (value) within an array. | ||
| | | | ||
| &nbsp;&nbsp;&nbsp; | ||
| | | | ||
'''''Scan Array'':''' | '''''Scan Array'':''' | ||
<pre> | |||
foreach($ini_array as $key = | foreach($ini_array as $key => $value){ | ||
Do something | Do something | ||
} | } | ||
</pre> | |||
'''''Scan Array and print'':''' | '''''Scan Array and print'':''' | ||
<pre> | |||
foreach($ini_array as $key = | foreach($ini_array as $key => $value){ | ||
print | print "Key = $key Value = $value"; | ||
} | } | ||
</pre> | |||
|} | |} | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' | ||
=== Test Code === | === Test Code === | ||
{| | {| | ||
|-valign= | |-valign="top" | ||
| | | | ||
'''''Edit Script''''' | '''''Edit Script''''' | ||
Line 189: | Line 190: | ||
* Writes array to file | * Writes array to file | ||
| | | | ||
<pre> | |||
<?php | |||
$ini_array = file( | $ini_array = file("cron.ini"); | ||
foreach($ini_array as $key = | foreach($ini_array as $key => $value){ | ||
print | print "Key = $key Value = $value"; | ||
} | } | ||
file_put_contents( | file_put_contents("out_cron.txt",$ini_array); | ||
? | ?> | ||
</pre> | |||
|-valign= | |-valign="top" | ||
| | | | ||
'''''Run Script''''' | '''''Run Script''''' | ||
Line 211: | Line 212: | ||
'''''Important Note'':''' | '''''Important Note'':''' | ||
The line: '''print | The line: '''print "Key = $key Value = $value";''' does not require a new line character '''"\n"''' each line read from a file is intact new line characters are not stripped. Hence each value (line) in the array contains a new line character. | ||
| | | | ||
<pre> | |||
Key = 0 Value = ; Test example file for cron timers | Key = 0 Value = ; Test example file for cron timers | ||
Key = 1 Value = ; Period values hourly, daily or weekly | Key = 1 Value = ; Period values hourly, daily or weekly | ||
Line 234: | Line 235: | ||
Key = 16 Value = ref = | Key = 16 Value = ref = | ||
Press any key to continue . . . | Press any key to continue . . . | ||
</pre> | |||
|} | |} | ||
'''''[[#top | Top]]''''' | '''''[[#top | Top]]''''' |