当前位置: 首页>>代码示例>>PHP>>正文


PHP curry函数代码示例

本文整理汇总了PHP中curry函数的典型用法代码示例。如果您正苦于以下问题:PHP curry函数的具体用法?PHP curry怎么用?PHP curry使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了curry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init($param = 0)
 {
     if (curry($_POST['pst'])) {
         if (!curry($_SESSION['userInformation'])) {
             echo json_encode(['code' => 0, 'msg' => 'You need to be logged in to logged out!', 'showTime' => 3000]);
             exit;
         } else {
             unset($_SESSION['userInformation']);
             unset($_COOKIE['gpl']);
             setcookie("gpl", "NOTSET", time() - 1, "/");
             if (curry($_SESSION['userInformation'])) {
                 echo json_encode(['code' => 0, 'msg' => 'Something went wrong while logging you out.', 'showTime' => 3000]);
             } else {
                 echo json_encode(['code' => 1]);
             }
         }
         exit;
     } else {
         if (!curry($_SESSION['userInformation'])) {
             header("Location: /Planningsysteem/login/?e=rl");
             exit;
         } else {
             unset($_SESSION['userInformation']);
             unset($_COOKIE['gpl']);
             setcookie("gpl", "NOTSET", time() - 1, "/");
             if (curry($_SESSION['userInformation'])) {
                 header("Location: /Planningsysteem/login/?e=f");
                 exit;
             } else {
                 header("Location: /Planningsysteem/login/?e=s");
                 exit;
             }
         }
     }
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:35,代码来源:logoutController.php

示例2: test_curry

function test_curry()
{
    $a = function ($a, $b) {
        return $a + $b;
    };
    $add5 = curry($a, 5);
    return is_identical($add5(10), 15);
}
开发者ID:Burgestrand,项目名称:Funcy,代码行数:8,代码来源:funcy.php

示例3: init

 public function init($param = 0)
 {
     if (curry($_SESSION['userInformation'])) {
         $this->_userInfo = $_SESSION['userInformation'];
     } else {
         header("Location: /Planningsysteem/login/");
     }
     if (curry($_POST['oldPassword']) && curry($_POST['newPassword']) && curry($_POST['repeatNewPassword'])) {
         if (empty($_POST['oldPassword'])) {
             echo json_encode(['code' => 0, 'msg' => 'Old password may not be empty.', 'showTime' => 2000]);
             exit;
         }
         if (empty($_POST['newPassword'])) {
             echo json_encode(['code' => 0, 'msg' => 'New password may not be empty.', 'showTime' => 2000]);
             exit;
         }
         if (empty($_POST['repeatNewPassword'])) {
             echo json_encode(['code' => 0, 'msg' => 'Repeated new password may not be empty.', 'showTime' => 2000]);
             exit;
         }
         if ($_POST['newPassword'] != $_POST['repeatNewPassword']) {
             echo json_encode(['code' => 0, 'msg' => 'Passwords do not match!', 'showTime' => 2000]);
         }
         if ($_POST['newPassword'] == $_POST['oldPassword']) {
             echo json_encode(['code' => 0, 'msg' => 'Old password and your new password may not be the same!', 'showTime' => 3000]);
         }
         if (strlen($_POST['newPassword']) < 5) {
             echo json_encode(['code' => 0, 'msg' => 'New password may not be shorter than 5 characters!', 'showTime' => 2000]);
         }
         if (strlen($_POST['repeatNewPassword']) < 5) {
             echo json_encode(['code' => 0, 'msg' => 'Repeated new password may not be shorter than 5 characters!', 'showTime' => 2000]);
         }
         $this->_userModel = $this->model('user');
         if ($this->_userModel->verifyPasswordByUserInfo($this->_userInfo, $_POST['oldPassword'])) {
             if ($this->_userModel->updatePasswordByUserID($this->_userInfo->werknemer_id, $_POST['newPassword'])) {
                 unset($_SESSION['userInformation']);
                 if (curry($_COOKIE['gpl'])) {
                     unset($_COOKIE['gpl']);
                     setcookie("gpl", "NOTSET", time() - 1, "/");
                 }
                 echo json_encode(['code' => 1]);
             } else {
                 echo json_encode(['code' => 0, 'msg' => 'Failed to update your password.', 'showTime' => 2000]);
             }
         } else {
             echo json_encode(['code' => 0, 'msg' => 'Incorrect (old) password entered!', 'showTime' => 3000]);
         }
     } else {
         if ($this->isLoggedIn()) {
             $this->view('head', ['title' => 'Wachtwoord Veranderen - GrouPlaylist']);
             $this->view('header', ['loggedInUserInfo' => $_SESSION['userInformation']]);
             $this->view('changePassword', ['loggedInUserInfo' => $_SESSION['userInformation']]);
             $this->view('footer', ['loggedInUserInfo' => $_SESSION['userInformation']]);
         } else {
             header("Location: /Planningsysteem/login/");
         }
     }
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:58,代码来源:changePasswordController.php

示例4: init

 public function init($param = 0)
 {
     if (!curry($_SESSION['userInformation'])) {
         header("Location: /Planningsysteem/login/");
     }
     $this->view('head', ['title' => 'Home | Planningsysteem']);
     $this->view('header', ['loggedInUserInfo' => $_SESSION['userInformation']]);
     $this->view('footer', ['loggedInUserInfo' => $_SESSION['userInformation']]);
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:9,代码来源:calendarController.php

示例5: test_curry_function_with_arity_arg

 public function test_curry_function_with_arity_arg()
 {
     $strtime = curry('microtime');
     $floattime = call_user_func(curry('microtime', 2), true);
     $strstrWithBrianAndColon = call_user_func(call_user_func(curry('strstr', 3), 'brian:scaturro'), ':');
     $this->assertTrue(is_string($strtime()));
     $this->assertTrue(is_float($floattime()));
     $this->assertEquals('brian', $strstrWithBrianAndColon(true));
 }
开发者ID:brianium,项目名称:phunc,代码行数:9,代码来源:CurryTest.php

示例6: _cached_curry

/**
 * @param $fn
 * @return \Closure
 */
function _cached_curry($fn)
{
    static $cache = [];
    if (isset($cache[$fn])) {
        return $cache[$fn];
    } else {
        return $cache[$fn] = curry($fn);
    }
}
开发者ID:camspiers,项目名称:php-fp,代码行数:13,代码来源:lib.php

示例7: it_tests_curry

 /**
  * @test
  */
 public function it_tests_curry()
 {
     $add = function ($a, $b) {
         return $a + $b;
     };
     $threeParams = function ($a, $b, $c) {
         return $a + $b + $c;
     };
     $addTwo = curry($add, 2);
     $addFive = curry($threeParams, 5);
     $this->assertEquals(5, $addTwo(3));
     $this->assertEquals(10, $addFive(3, 2));
 }
开发者ID:domynation,项目名称:domynation-framework,代码行数:16,代码来源:FunctionalTest.php

示例8: init

 public function init($param = 0)
 {
     if (curry($_SESSION['userInformation'])) {
         header("Location: /Planningsysteem/");
         exit;
     }
     if (curry($_SESSION['tmpUserInformation'])) {
         $this->_userInfo = $_SESSION['tmpUserInformation'];
     } else {
         // e = you already updated
         header("Location: /Planningsysteem/login/?e=yau");
         exit;
     }
     if (curry($_POST['password']) && curry($_POST['repeatPassword'])) {
         $this->_userModel = $this->model('user');
         if ($_POST['password'] != "") {
             $this->_password = $this->_userModel->encodeValueByString($_POST['password']);
         } else {
             echo json_encode(['code' => 0, 'msg' => 'Password cannot be empty!']);
             exit;
         }
         if ($_POST['repeatPassword'] != "") {
             $this->_repeatPassword = $this->_userModel->encodeValueByString($_POST['repeatPassword']);
         } else {
             echo json_encode(['code' => 0, 'msg' => 'Repeated Password cannot be empty!']);
             exit;
         }
         if ($this->_password != $this->_repeatPassword) {
             echo json_encode(['code' => 0, 'msg' => 'Passwords do not match!']);
             exit;
         }
         if ($this->_userModel->changePasswordByUserID($this->_userInfo->werknemer_id, $this->_password)) {
             if ($this->_userModel->setCustomPassword($this->_userInfo->werknemer_id)) {
                 unset($_SESSION['tmpUserInformation']);
                 echo json_encode(['code' => 1]);
             } else {
                 echo json_encode(['code' => 0, 'msg' => 'Failed to update your password.']);
             }
         } else {
             echo json_encode(['code' => 0, 'msg' => 'Failed to change password!']);
         }
     } else {
         $this->view('head', ['title' => 'Set Password | ' . $this->_userInfo->username]);
         $this->view('header', ['loggedInUserInfo' => false]);
         $this->view('firstLogin', ['userInfo' => $this->_userInfo]);
         $this->view('footer', ['loggedInUserInfo' => false]);
     }
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:48,代码来源:setPasswordController.php

示例9: isLoggedIn

 /**
  *
  * This function checks if someone is logged in, if not, he will be redirected
  * to the login page.
  */
 public function isLoggedIn($adminRequired = 0)
 {
     if (curry($_SESSION['userInformation'])) {
         if ($adminRequired) {
             if ($_SESSION['userInformation']->is_admin) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return true;
         }
     } else {
         header("Location: /Planningsysteem/login/");
     }
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:21,代码来源:Controller.php

示例10: init

 public function init($param = 0)
 {
     if ($this->isLoggedIn(true)) {
         if (curry($_POST['customerName'])) {
             $this->_userModel = $this->model('user');
             if ($this->_userModel->createCustomer($_POST['customerName'], $_POST['customerAdres'], $_POST['customerPhone'], $_POST['customerPostal'], $_POST['customerEmail'], $_POST['customerContact'], $_POST['customerPlaats'])) {
                 echo json_encode(['code' => 1]);
             } else {
                 echo json_encode(['code' => 0, 'msg' => 'Kon gebruiker niet aanmaken.']);
             }
         } else {
             $this->view('head', ['title' => 'Klant Aanmaken - Planningsysteem']);
             $this->view('header', ['loggedInUserInfo' => $_SESSION['userInformation']]);
             $this->view('createCustomer', ['userInfo' => $_SESSION['userInformation']]);
             $this->view('footer', ['loggedInUserInfo' => $_SESSION['userInformation']]);
         }
     } else {
         header("Location: /Planningsysteem/");
     }
 }
开发者ID:TheRinseM,项目名称:Planningsysteem,代码行数:20,代码来源:createCustomerController.php

示例11: send

    public function send(EmailMessage $message, $data = [])
    {
        $recipient = function (Email $email) {
            return $email->getValue();
        };
        $commaSeparated = curry('implode', ', ');
        $formatRecipients = compose($commaSeparated, map($recipient));
        $recipientsString = $formatRecipients($message->recipients);
        // Append the original recipients to the end of the email for debug purposes
        $message->body .= <<<EOT


------------- DEBUG INFO ----------------

Original recipients: {$recipientsString}

----------------------------------------------
EOT;
        // Alter the recipients to send them all to the dev mailbox
        $message->recipients = [$this->destinationEmail];
        // Send the email using the normal mailer
        $this->mailer->send($message, $data);
    }
开发者ID:domynation,项目名称:domynation-framework,代码行数:23,代码来源:DebugMailer.php

示例12: groupBy

/**
 * Converts an array to an associative array, based on the result of calling `$fn`
 * on each element, and grouping the results according to values returned.
 * Note that `$fn` should take an item from the list and return a string.
 * ```php
 * $persons = [
 *     ['name' => 'foo', 'age' => 11],
 *     ['name' => 'bar', 'age' => 9],
 *     ['name' => 'baz', 'age' => 16],
 *     ['name' => 'zeta', 'age' => 33],
 *     ['name' => 'beta', 'age' => 25]
 * ];
 * $phase = function($person) {
 *     $age = $person['age'];
 *     if ($age < 13) return 'child';
 *     if ($age < 19) return 'teenager';
 *     return 'adult';
 * };
 * groupBy($phase, $persons);
 * // [
 * //  'child' => [['name' => 'foo', 'age' => 11], ['name' => 'bar', 'age' => 9]],
 * //  'teenager' => [['name' => 'baz', 'age' => 16]],
 * //  'adult' => [['name' => 'zeta', 'age' => 33], ['name' => 'beta', 'age' => 25]]
 * // ]
 * ```
 *
 * @signature (a -> String) -> [a] -> {String: a}
 * @param  callable $fn
 * @param  array $list
 * @return array
 */
function groupBy()
{
    $groupBy = function ($fn, $list) {
        return reduce(function ($result, $item) use($fn) {
            $index = $fn($item);
            if (!isset($result[$index])) {
                $result[$index] = [];
            }
            $result[$index][] = $item;
            return $result;
        }, [], $list);
    };
    return apply(curry($groupBy), func_get_args());
}
开发者ID:tarsana,项目名称:functional,代码行数:45,代码来源:list.php

示例13: product

/**
 * Computes the product of an array of numbers.
 * ```php
 * product([1, 2, 3, 4]) // 24
 * product([]) // 1
 * ```
 *
 * @signature [Number] -> Number
 * @param  array $numbers
 * @return int|float
 */
function product()
{
    return apply(curry(function ($numbers) {
        return reduce(multiply(), 1, $numbers);
    }), func_get_args());
}
开发者ID:tarsana,项目名称:functional,代码行数:17,代码来源:math.php

示例14: __

// Grouping syntax
function __()
{
    return array_merge(['grouped' => true], func_get_args());
}
call_user_func(function () {
    $interpret = null;
    $call = curry(function (array $env, $f, $arg) use(&$interpret) {
        return op($f, $interpret($env, $arg));
    });
    $chain = curry(function (array $env, array $calls) use($call) {
        return array_reduce(array_diff_key($calls, ['grouped' => '']), $call($env), function ($x) {
            return $x;
        });
    });
    $plumb = curry(function (array $env, array $expr, $arg) use($chain) {
        return $expr ? $chain(array_merge([$arg], $env), $expr) : $arg;
    });
    $interpret = curry(function (array $e, $x) use($chain, $plumb) {
        // Assume ints and arrays are Plumb; anything else is PHP
        if (is_int($x)) {
            return $e[$x];
        }
        if (is_array($x)) {
            return isset($x['grouped']) ? $chain($e, $x) : $plumb($e, $x);
        }
        return $x;
    });
    // Interpret $f in an empty environment
    defun('plumb', $plumb([]));
});
开发者ID:Warbo,项目名称:php-plumb,代码行数:31,代码来源:plumb.php

示例15: chunks

/**
 * Splits a string into chunks without spliting any group surrounded with some
 * specified characters. `$surrounders` is a string where each pair of characters
 * specifies the starting and ending characters of a group that should not be split.
 * ```php
 * $groups = chunks('(){}', ',');
 * $groups('1,2,(3,4,5),{6,(7,8)},9'); // ['1', '2', '(3,4,5)', '{6,(7,8)}', '9']
 *
 * $names = chunks('()""', ' ');
 * $names('Foo "Bar Baz" (Some other name)'); // ['Foo', 'Bar Baz', 'Some other name']
 * ```
 *
 * @signature String -> String -> String -> [String]
 * @param  string $surrounders
 * @param  string $separator
 * @param  sring $text
 * @return array
 */
function chunks()
{
    $chunks = function ($surrounders, $separator, $text) {
        // Let's assume some values to understand how this function works
        // surrounders = '""{}()'
        // separator = ' '
        // $text = 'foo ("bar baz" alpha) beta'
        $surrounders = map(slices(1), slices(2, $surrounders));
        // [['"'. '"'], ['{'. '}'], ['(', ')']]
        $openings = map(get(0), $surrounders);
        // ['"', '{', '(']
        $closings = map(get(1), $surrounders);
        // ['"', '}', ')']
        $numOfSurrounders = length($surrounders);
        // 3
        $indexes = keys($surrounders);
        // [0, 1, 2]
        $items = split($separator, $text);
        // ['foo', '("bar', 'baz"', 'alpha)', 'beta']
        // The initial state
        $state = (object) ['chunks' => [], 'counts' => array_fill(0, $numOfSurrounders, 0), 'total' => 0];
        // We will iterate over $items and update the $state while adding them
        // For each item we need to update counts and chunks
        // Updates count for a single surrender (the surrender at $index)
        // $item : the item we are adding
        // $counts : the previous counts
        $updateCountAt = curry(function ($item, $counts, $index) use($openings, $closings) {
            $count = occurences(__(), $item);
            return $openings[$index] == $closings[$index] ? ($counts[$index] + $count($openings[$index])) % 2 : $counts[$index] + $count($openings[$index]) - $count($closings[$index]);
        });
        // Updates counts for all surrenders
        $updateCounts = curry(function ($item, $counts) use($indexes, $updateCountAt) {
            return map($updateCountAt($item, $counts), $indexes);
        });
        // Adds an item to the state and returns a new state
        $addItem = function ($state, $item) use($separator, $updateCounts) {
            $counts = $updateCounts($item, get('counts', $state));
            $newChunks = 0 == $state->total ? append($item, $state->chunks) : append(last($state->chunks) . $separator . $item, init($state->chunks));
            return (object) ['chunks' => $newChunks, 'counts' => $counts, 'total' => sum($counts)];
        };
        // Returns the chunks of the resulting state after adding all items
        return get('chunks', reduce($addItem, $state, $items));
    };
    return apply(curry($chunks), func_get_args());
}
开发者ID:tarsana,项目名称:functional,代码行数:63,代码来源:string.php


注:本文中的curry函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。