本文整理汇总了PHP中contains函数的典型用法代码示例。如果您正苦于以下问题:PHP contains函数的具体用法?PHP contains怎么用?PHP contains使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了contains函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FormPost
public function FormPost()
{
$out = array();
$out["map"] = array();
foreach (getpost() as $name => $value) {
if (matches($name, "map")) {
$map = json_decode(FormHelper::Decode($value));
foreach ($map as $mapped) {
$parts = explode('|', $mapped);
if (contains($parts[0], '__')) {
$d = explode('__', $parts[0]);
if (!isset($out["map"][$d[0]])) {
$out["map"][$d[0]] = array();
}
$out["map"][$d[0]][$d[1]] = AJAX::fp($parts[1]);
} else {
$mapped[$parts[0]] = AJAX::fp($parts[1]);
}
}
} else {
if (contains($name, '__')) {
$d = explode("__", $name);
if (!isset($out[$d[0]])) {
$out[$d[0]] = array();
}
$out[$d[0]][$d[1]] = base64_decode(urldecode($value));
} else {
$out[$name] = FormHelper::Decode($value);
}
}
}
$out['signal'] = json_decode($out['signal'], true);
return $out;
}
示例2: active_plugin
function active_plugin($plugin, $page)
{
$form_plugin = array("validation", "select");
if ($plugin == "isotope" && (startsWith($page, '/profile/all') || startsWith($page, '/circle/all'))) {
return false;
}
if (in_array($plugin, $form_plugin) && (contains($page, '/edit') || contains($page, '/add'))) {
return true;
}
if ($plugin == "jasny" && (startsWith($page, '/profile/add') || startsWith($page, '/profile/edit'))) {
return true;
}
if ($plugin == "formhelpers" && startsWith($page, '/profile/')) {
return true;
}
if ($plugin == "mixitup" && (startsWith($page, '/profile/all') || startsWith($page, '/circle/all'))) {
return true;
}
if ($plugin == "isotope" && (startsWith($page, '/card') || startsWith($page, '/storyboard') || startsWith($page, '/card/all') || startsWith($page, '/profile/all') || startsWith($page, '/circle/all'))) {
return true;
}
if ($plugin == "rcarousel" && startsWith($page, '/circle/view')) {
return true;
}
return false;
}
示例3: sendMsg
function sendMsg($sender, $reciever, $recieverPhone, $content, $sendtime)
{
global $mysql, $userAndPswd, $corpName, $apiUrl, $MsgErrorCode, $BlackListWords;
foreach ($BlackListWords as $blackWord) {
if (contains($content, $blackWord)) {
return array('status' => 'successful', 'errMsg' => "含有非法内容:" . $blackWord);
}
}
$content = $corpName . $content;
$action = $sendtime == null ? "sendsms.action?" : "sendtimesms.action";
$url = $apiUrl . $action . $userAndPswd . "&phone={$recieverPhone}&message=" . urlencode($content) . "&sendtime={$sendtime}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 获取数据返回
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
// 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
$res = curl_exec($ch);
if ($res == false) {
throw new Exception("向短信提供商请求失败!");
} else {
$error = getValue($res, "error");
$message = isset($MsgErrorCode[$error]) ? $MsgErrorCode[$error] : "未知";
$obj = array("id" => date("YmdHis") . str_pad(rand(0, 9999), 4, rand(0, 9), STR_PAD_LEFT), "sender" => $sender, "reciever" => $reciever, "recieverPhone" => $recieverPhone, "status" => $error, "result" => $message, "content" => $content);
$mysql->DBInsertAsArray('msg_log', $obj);
if ($error != "0") {
throw new Exception("错误代码:" . $error . " " . $message);
}
}
return array('status' => 'successful', 'errMsg' => '');
}
示例4: getFormQuestions
function getFormQuestions($db, $filters = null)
{
if (!$db || $db->offline) {
$questions = readJsonFile("../api/form_data.json");
if (isset($questions["questions"])) {
$questions = $questions["questions"];
}
return $questions;
}
$p = array("table" => "form_question", "order_by" => "section_id, position, id", "required" => 1);
if ($filters) {
foreach ($filters as $key => &$value) {
if (contains($value, ",")) {
$value = explode(",", $value);
}
if ($value) {
$p[$key] = $value;
}
}
}
$form_questions = $db->selectWhere($p);
$p = array("table" => "form_answer", "order_by" => "question_id, position, id");
$form_answers = $db->selectWhere($p);
//group join the 2 results
return $db->groupJoinResults($form_questions, $form_answers, "form_answers", "id", "question_id");
}
示例5: testSigninYourAccountMenuIsNotDisplayedToNonAuthenticatedUser
/**
* A user that isn't logged in shouldn't see the "Your Account" menu (including, "Your Widgets",
* "Change Password", etc).
*/
function testSigninYourAccountMenuIsNotDisplayedToNonAuthenticatedUser()
{
$this->createHomepageWidgets();
$this->get('/account/signout');
$this->get('/');
assertFalse(contains($this->currentPageContent(), "Your Account"));
assertFalse(contains($this->currentPageContent(), "Change Password"));
assertFalse(contains($this->currentPageContent(), "Sign Out"));
assertTrue(contains($this->currentPageContent(), "Sign In"));
}
示例6: itCanCreateAResponseDefinition
/** @test */
public function itCanCreateAResponseDefinition()
{
$schemaFile = 'file://' . __DIR__ . '/../fixtures/petstore.json';
$factory = new SwaggerSchemaFactory();
$schema = $factory->createSchema($schemaFile);
$responseDefinition = $schema->getRequestDefinition('addPet')->getResponseDefinition(200);
assertThat($responseDefinition, isInstanceOf(ResponseDefinition::class));
assertThat($responseDefinition->getContentTypes(), contains('application/json'));
assertThat($responseDefinition->getBodySchema(), isType('object'));
assertThat($responseDefinition->getStatusCode(), equalTo(200));
}
示例7: testContains
/**
* BootstrapTest::testContains()
*
* @return void
*/
public function testContains()
{
$strings = [['auto', 'to', true], ['auto', 'ut', true], ['auto', 'To', true], ['auto', 'ot', false]];
foreach ($strings as $string) {
$is = contains($string[0], $string[1]);
//pr(returns($is). ' - expected '.returns($string[2]));
$this->assertEquals($string[2], $is);
}
$is = contains('Auto', 'To', true);
$this->assertEquals(false, $is);
}
示例8: testBalanceLookupElegantlyDetectsSiteMaintenanceAtBlockchainDotInfo
function testBalanceLookupElegantlyDetectsSiteMaintenanceAtBlockchainDotInfo()
{
# Special address for mocking a "Site Under Maintenance" response from Blockchain.info.
$address = '1TestForDowntimeX1iTDhViXbrogKqzbt';
try {
BlockchainDotInfo\getBalanceInSatoshis($address);
fail("Expected to get exception for lookup on address {$address}");
} catch (NetworkError $e) {
assertTrue(contains(strtolower($e->getMessage()), 'maintenance'));
}
}
示例9: test_3_pages
function test_3_pages()
{
$csv = grab_rubrica("http://www.unipr.it/rubrica", 3);
$testStrings = array("AGNESINI Prof. Alex,alex.agnesini@unipr.it,+39 0521 032552", "ALFIERI Prof. Roberto,roberto.alfieri@unipr.it,+39 0521 906214", "ARGIROPOULOS Prof. DIMITRIS,,");
foreach ($testStrings as $test) {
if (!contains($csv, $test)) {
exit("Test Failed on: " . $test . PHP_EOL);
}
}
echo "Passed all tests." . PHP_EOL;
}
示例10: trimZeros
function trimZeros($num)
{
if (!is_numeric($num)) {
throw new InvalidArgumentException("Only numeric values accepted");
}
$numStr = (string) $num;
if (!contains($num, '.')) {
return ltrim($numStr, '0');
} else {
return trim($num, '0.');
}
}
示例11: findMimeTypeUsingUrl
function findMimeTypeUsingUrl($url)
{
$UserMime = "application/vnd.jyu.nfleet.user-2.1+json";
$ProblemMime = "application/vnd.jyu.nfleet.problem-2.0+json";
$ProblemSetMime = "application/vnd.jyu.nfleet.problemset-2.0+json";
$ProblemSettingsMime = "application/vnd.jyu.nfleet.problemsettings-2.1+json";
$VehicleSetMime = "application/vnd.jyu.nfleet.vehicleset-2.1+json";
$VehicleMime = "application/vnd.jyu.nfleet.vehicle-2.1+json";
$TaskSetMime = "application/vnd.jyu.nfleet.taskset-2.1+json";
$TaskMime = "application/vnd.jyu.nfleet.task-2.1+json";
$PlanMime = "application/vnd.jyu.nfleet.plan-2.0+json";
$ImportMime = "application/vnd.jyu.nfleet.import-2.2+json";
$RouteMime = "application/vnd.jyu.nfleet.route-2.0+json";
$RouteEventMime = "application/vnd.jyu.nfleet.routeevent-2.0+json";
$RouteEventSetMime = "application/vnd.jyu.nfleet.routeeventset-2.0+json";
if (strlen($url) == 0) {
return "application/json";
}
if (endsWith($url, "/settings")) {
return $ProblemSettingsMime;
}
if (contains($url, "plan")) {
return $PlanMime;
}
if (endsWith($url, "/route")) {
return $RouteMime;
}
if (endsWith($url, "/events") || endsWith($url, "/events/")) {
return $RouteEventSetMime;
}
if (contains($url, "/events/")) {
return $RouteEventMime;
}
if (endsWith($url, "tasks")) {
return $TaskSetMime;
}
if (contains($url, "tasks/")) {
return $TaskMime;
}
if (endsWith($url, "vehicles")) {
return $VehicleSetMime;
}
if (contains($url, "vehicles/")) {
return $VehicleMime;
}
if (endsWith($url, "problems")) {
return $ProblemSetMime;
}
if (contains($url, "problems/")) {
return $ProblemMime;
}
return "application/json";
}
示例12: addToStack
function addToStack(&$metadata, $bbox, $lon, $lat, $provider, $o)
{
if (contains($bbox, $lon, $lat)) {
$k = "{$lon},{$lat}";
if (!array_key_exists($k, $metadata)) {
$metadata[$k] = array();
}
if (!array_key_exists($provider, $metadata[$k])) {
$metadata[$k][$provider] = array();
}
array_push($metadata[$k][$provider], $o);
}
}
示例13: testReelLife
public function testReelLife()
{
$test = 'created_at';
$this->assertTrue(contains('created_at', $test));
$this->assertTrue(contains('*_at', $test));
$this->assertTrue(contains('*_at*', $test));
$this->assertFalse(contains('_at*', $test));
$this->assertFalse(contains('_at', $test));
$this->assertTrue(contains('*created*', $test));
$this->assertTrue(contains('created*', $test));
$this->assertFalse(contains('created', $test));
$this->assertTrue(contains('*_at', $test . ' date'));
$this->assertFalse(contains('_at', $test . '_date'));
}
示例14: part_1
function part_1($line)
{
global $not_contains, $vowels;
if (contains($line, $not_contains)) {
return false;
}
if (!vowels($line, $vowels)) {
return false;
}
if (!preg_match('/([a-z])\\1{1,}/', $line)) {
return false;
}
return true;
}
示例15: test_delete_behaviour
public function test_delete_behaviour()
{
$chain = new Chain();
$chain->add('fred')->add('wilma')->add('betty')->add('barney');
assertThat($chain->getTokens(), contains(array('fred', 'wilma', 'betty', 'barney')));
$chain->delete('wilma');
assertThat($chain->getTokens(), contains(array('fred', 'betty', 'barney')));
$chain->delete('barney');
assertThat($chain->getTokens(), contains(array('fred', 'betty')));
$chain->delete('fred');
assertThat($chain->getTokens(), contains(array('betty')));
$chain->delete('betty');
assertThat($chain->getTokens(), contains(array()));
}