2017 © Pedro Peláez
 

library ans

Standart json-answer for php handlers

image

infrajs/ans

Standart json-answer for php handlers

  • Saturday, February 17, 2018
  • by akiyatkin
  • Repository
  • 5 Watchers
  • 0 Stars
  • 753 Installations
  • PHP
  • 39 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

Latest Stable Version Total Downloads, (*1)

API for json-answer PHP-scripts

An easy way to work with the parameters of the GET. API to return the result of the script - the success or error., (*2)

Ans::ans - Is used to output data in json format.

Ans::ans([array $ans]), (*3)

Ans::ans(['test' => 'Test data']);

***
{
  "test": "Test data"
}
***

Ans::err - Is used to display an error message $msg and data $ans in json format.

Ans::err([array $ans [, string $msg]]), (*4)

$test = ['test' => 'Test data'];
Ans::err($test, 'Error');

***
{
  "test": "Test data",
  "result": 0,
  "msg": "Error"
}
***

Ans::log - Is used to display an error message $msg and data $ans in json format. Write down all the error in log stating name of the file in which the error occurred. If you have $msg, he is substituted in the end of the name

Ans::log([array $ans [, string $msg [, mixed $data [, bool $debug]]]]), (*5)

Ans::ret - Is used to output data in json format, this adds to the array $msg with the passed argument.

Ans::ret([array $ans [, string $msg]]), (*6)

$test = ['test' => 'Test data'];
Ans::ret($test, 'Add msg');

***
{
    "test": "Test data",
    "msg": "Add msg",
    "result": 1
}
***

Ans::txt - Used to display text

Ans::txt(string $ans), (*7)

$test = 'Test string';
Ans::txt($test);

***
Test string
***

Ans::GET - If the url passed to the request parameter name equal to $name, then this method will return the value of this parameter and if the provided type is $type, then the variable contained in $_GET[$name] will be assigned the new type.

Ans::GET(string $name [, string $type [, $def = null]]), (*8)

$_GET['test'] = 50;
var_dump(Ans::GET('test'));
var_dump(Ans::GET('test', 'string'));
var_dump(Ans::GET('test', 'array'));
var_dump(Ans::GET('test', 'bool'));
var_dump(Ans::GET('test', 'null'));
var_dump(Ans::GET('test', 'float'));
var_dump(Ans::GET('test', 'object'));

***
int 50
string '50' (length=2)
array (size=1) 0 => int 50
boolean true
null
float 50
object(stdClass)[4] public 'scalar' => int 50
***

Ans::ans - Используется для вывода данных в формате json.

Ans::ans([array $ans]), (*9)

Ans::ans(['test' => 'Тестовые данные']);

***
{
  "test": "Тестовые данные"
}
***

Ans::err - Используется для вывода ошибки с сообщением $msg и данными $ans в формате json.

Ans::err([array $ans [, string $msg]]), (*10)

$test = ['test' => 'Тестовые данные'];
Ans::err($test, 'Ошибка');

***
{
  "test": "Тестовые данные",
  "result": 0,
  "msg": "Ошибка"
}
***

Ans::log - Используется для вывода ошибки с сообщением $msg и данными $ans в формате json, при этом записыват ошибку в log с указанием имени файла в котором произошла ошибка и в конце имени файла подставляет $msg, если имеется.

Ans::log([array $ans [, string $msg [, mixed $data [, bool $debug]]]]), (*11)

Ans::ret - Используется для вывода данных в формате json, при этом добавляется в массив $msg с переданным аргументом.

Ans::ret([array $ans [, string $msg]]), (*12)

$test = ['test' => 'Тестовые данные'];
Ans::ret($test, 'Добавленное сообщение');

***
{
    "test": "Тестовые данные",
    "msg": "Добавленное сообщение",
    "result": 1
}
***

Ans::txt - Используется для вывода текста

Ans::txt(string $ans), (*13)

$test = 'Тестовый текст';
Ans::txt($test);

***
Тестовый текст
***

Ans::GET - Если в url запросе передано имя параметра равное $name, то данный метод вернет значение этого параметра и если передан тип $type, то переменной, которая содержится в $_GET[$name] будет присвоен новый тип

Ans::GET(string $name [, string $type [, $def = null]]), (*14)

$_GET['test'] = 50;
var_dump(Ans::GET('test'));
var_dump(Ans::GET('test', 'string'));
var_dump(Ans::GET('test', 'array'));
var_dump(Ans::GET('test', 'bool'));
var_dump(Ans::GET('test', 'null'));
var_dump(Ans::GET('test', 'float'));
var_dump(Ans::GET('test', 'object'));

***
int 50
string '50' (length=2)
array (size=1) 0 => int 50
boolean true
null
float 50
object(stdClass)[4] public 'scalar' => int 50
***

The Versions

17/02 2018

dev-master

9999999-dev https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

06/05 2017

1.0.8

1.0.8.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

09/04 2017

1.0.7

1.0.7.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

12/09 2016

1.0.6

1.0.6.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

20/08 2016

1.0.5

1.0.5.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

26/05 2016

1.0.4

1.0.4.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

26/05 2016

1.0.3

1.0.3.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

07/03 2016

1.0.2

1.0.2.0 https://github.com/infrajs/ans

Standart json-answer for php handlers

  Sources   Download

GPL3

12/12 2015

1.0.1

1.0.1.0

Standart json-answer for php handlers

  Sources   Download

GPL3

05/12 2015

1.0.0

1.0.0.0

Standart json-answer for php handlers

  Sources   Download

GPL3