Документация PHP


Примеры

Objective interface

Примеры

PHP Manual


Extended interface

The extended interface provides a small suite of functions that allow the user to define an arbitrary number of named counters with unique settings. The basic interface can be used in parallel with the extended interface.

Пример #1 "counter"'s extended interface

<?php
function print_counter_info($counter)
{
    if (
is_resource($counter)) {
        
printf("Counter's name is '%s' and is%s persistent. Its current value is %d.\n",
            
counter_get_meta($counterCOUNTER_META_NAME),
            
counter_get_meta($counterCOUNTER_META_IS_PERSISTENT) ? '' ' not',
            
counter_get_value($counter));
    } else {
      print 
"Not a valid counter!\n";
    }
}

if ((
$counter_one counter_get_named("one")) === NULL) {
    
$counter_one counter_create("one"0COUNTER_FLAG_PERSIST);
}
counter_bump_value($counter_one2);
$counter_two counter_create("two"5);
$counter_three counter_get_named("three");
$counter_four counter_create("four"2COUNTER_FLAG_PERSIST COUNTER_FLAG_SAVE COUNTER_FLAG_NO_OVERWRITE);
counter_bump_value($counter_four1);

print_counter_info($counter_one);
print_counter_info($counter_two);
print_counter_info($counter_three);
print_counter_info($counter_four);
?>

When run once, the above example outputs:

Counter's name is 'one' and is persistent. Its current value is 2.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 3.

If run a second time within the same instance of PHP, it outputs:

Counter's name is 'one' and is persistent. Its current value is 4.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 4.

If then run a third time in a different instance of PHP, it outputs:

Counter's name is 'one' and is persistent. Its current value is 2.
Counter's name is 'two' and is not persistent. Its current value is 5.
Not a valid counter!
Counter's name is 'four' and is persistent. Its current value is 5.


Примеры

Objective interface

Примеры

PHP Manual

SAPE все усложнил?

MainLink - простая и прибыльная продажа ссылок!

Последние поступления:

Размещена 10 августа 2020 года

Я по ТВ видел, что через 10 лет мы будем жить лучше, чем в Германии...
Я не понял, что это они с Германией сделать хотят?!

читать далее…

ТехЗадание на Землю

Размещена 14 марта 2018 года

Пpоект Genesis (из коpпоpативной пеpеписки)

читать далее…

Шпаргалка по работе с Vim

Размещена 05 декабря 2017 года

Vim довольно мощный редактор, но работа с ним не всегда наглядна.
Например если нужно отредактировать какой-то файл например при помощи crontab, без знания специфики работы с viv никак.

читать далее…

Ошибка: Error: Cannot find a valid baseurl for repo

Размещена 13 сентабря 2017 года

Если возникает ошибка на centos 5 вида
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/

читать далее…

Linux Optimization

Размещена 30 июля 2012 года

Prelink

читать далее…