PHP Api


SUBMITTED BY: doublechar

DATE: April 24, 2016, 10:04 p.m.

UPDATED: April 24, 2016, 10:07 p.m.

FORMAT: Text only

SIZE: 481 Bytes

HITS: 7245

  1. <?php
  2. class APIOutput {
  3. private $isDataSet = false;
  4. private $data;
  5. public function setCode($code) {
  6. $this->code = $code;
  7. }
  8. public function setData($data) {
  9. $this->data = $data;
  10. $this->isDataSet = true;
  11. }
  12. public function out() {
  13. if ($this->isDataSet == false) {
  14. $out = ["code" => $this->code];
  15. }
  16. else {
  17. $out = ["code" => $this->code,
  18. "data" => $this->data];
  19. }
  20. return json_encode($out);
  21. }
  22. }
  23. ?>

comments powered by Disqus