Last active
August 26, 2018 11:46
-
-
Save rahuldottech/3ad60944374c6aaf657588787dd0bdcd to your computer and use it in GitHub Desktop.
Usage examples for varDx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'varDx.php'; | |
$dx = new \varDx\cDX; //create object | |
$dx->def('file1.txt'); //define data file | |
$a = "this is a string"; | |
$dx->write('val1', $a); //write key to file | |
$dx->modify('val1', "this is another string"); //modify value of key | |
echo $dx->read('val1'); //read value of key | |
if($dx->check('val1')){ //check if key exists | |
del('val1'); //delete key | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Say you have multiple users, and you want to store details of all of them in the same file. | |
In that case, you can do something like this: | |
*/ | |
require 'varDx.php'; | |
$dx = new \varDx\cDX; //create object | |
$dx->def('file1.txt'); //define data file | |
$user1 = "tom"; | |
$user2 = "tim"; | |
$dx->write($user1.'_address', "somevalue"); //write key to file | |
$dx->write($user2.'_address', "somevalue"); //write key to file | |
/* | |
Here the effective key names are "tom_address" and "tim_address". | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
You can create multiple objects to deal with multiple files too! | |
*/ | |
require 'varDx.php'; | |
$dx1 = new \varDx\cDX; //create object | |
$dx2 = new \varDx\cDX; //create another object | |
$dx1->def('file1.txt'); //define data file | |
$dx2->def('file2.txt'); //define data file | |
$dx1->write('val1', "somevalue"); //write key to file1.txt | |
$dx2->write('val1', "somevalue"); //write key to file2/txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment