PHP code example of viodev / php-result

1. Go to this page and download the library: Download viodev/php-result library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

viodev / php-result example snippets


Viodev\Result {
  +result: "success"
  +code: "action_success"
  +data: array:1 [
    "message" => "Success!"
  ]
}

$result->success EQUALS true
$result->false EQUALS false

$result = fail('action_fail', [
    'error' => 'An error occurred!'
]);

$result = Result::fail('action_fail', [
    'error' => 'An error occurred!'
]);

Viodev\Result {
  +result: "fail"
  +code: "action_fail"
  +data: array:1 [
    "message" => "An error occurred!"
  ]
}

$result->fail EQUALS true
$result->success EQUALS false