本文整理汇总了PHP中endswith函数的典型用法代码示例。如果您正苦于以下问题:PHP endswith函数的具体用法?PHP endswith怎么用?PHP endswith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了endswith函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_zip_files
function list_zip_files($id)
{
if (!($r = open_zip_archive($id))) {
return false;
}
$zip = $r["handle"];
$result = array();
$idx = 0;
while ($entry = zip_read($zip)) {
$path = zip_entry_name($entry);
$components = explode("/", $path);
$filename = $components[count($components) - 1];
/*
* Remove
* - filenames that begin with .
* - .class
* - .prefs
* - paths ending with / (directory names)
* - paths that contain .metadata
*/
if (substr($filename, 0, 1) != "." && !endswith($filename, ".class") && !endswith($filename, ".prefs") && !endswith($path, "/") && strpos($path, ".metadata") === FALSE) {
$result[$idx] = $filename;
}
$idx++;
}
zip_close($zip);
return $result;
}
示例2: initialize
function initialize()
{
$dir = opendir(dirname(__FILE__) . '/classes');
$this->field_types = array();
while ($filespec = readdir($dir)) {
if (!endswith($filespec, '.php')) {
continue;
}
if (strpos($filespec, 'Field') === false && strpos($filespec, 'Disposition') === false) {
continue;
}
$shortname = substr($filespec, 0, strpos($filespec, '.'));
if (substr($shortname, -4) == 'Base') {
continue;
}
$this->field_types[$this->Lang('field_type_' . $shortname)] = $shortname;
}
foreach ($this->field_types as $tName => $tType) {
if (substr($tType, 0, 11) == 'Disposition') {
$this->disp_field_types[$tName] = $tType;
}
}
$this->all_validation_types = array();
ksort($this->field_types);
$this->std_field_types = array($this->Lang('field_type_TextField') => 'TextField', $this->Lang('field_type_TextAreaField') => 'TextAreaField', $this->Lang('field_type_CheckboxField') => 'CheckboxField', $this->Lang('field_type_CheckboxGroupField') => 'CheckboxGroupField', $this->Lang('field_type_PulldownField') => 'PulldownField', $this->Lang('field_type_RadioGroupField') => 'RadioGroupField', $this->Lang('field_type_DispositionEmail') => 'DispositionEmail', $this->Lang('field_type_DispositionFile') => 'DispositionFile', $this->Lang('field_type_PageBreakField') => 'PageBreakField', $this->Lang('field_type_StaticTextField') => 'StaticTextField');
ksort($this->std_field_types);
}
示例3: showFiles
function showFiles()
{
echo "<h2>Icons</h2>\n";
echo '<table border="1">';
$list = array();
$d = dir(".");
while (false !== ($entry = $d->read())) {
if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png") || endswith($entry, ".EPS") || endswith($entry, ".PSD") || endswith($entry, ".md")) {
$list[] = $entry;
}
}
$d->close();
sort($list);
foreach ($list as $entry) {
echo '<tr>' . "\n";
echo '<td><a href="' . $entry . '">' . $entry . ' </a></td>' . "\n";
if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png")) {
// display as image
// would be good to add a limiting size here
echo '<td bgcolor="#C0C0C0"><a href="' . $entry . '"><img src="' . $entry . '" style="max-width:500px;max-height:500px;"></a></tr>' . "\n";
} else {
// link without display
echo '<td bgcolor="#C0C0C0"><a href="' . $entry . '" download="' . $entry . '">(download)</a></tr>' . "\n";
}
echo '</tr>' . "\n";
}
echo "</table>\n";
}
示例4: getFirstFileIn
function getFirstFileIn($dir)
{
global $filetype;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (endswith($file, $filetype)) {
return $file;
}
}
}
return false;
}
示例5: GetCachePath
public static function GetCachePath($mod)
{
// Récupérer et traiter la préférence du dossier
$cache_path = $mod->GetPreference("cache_path");
// Si la préférence commence par un "/" alors l'enlever
if (startswith($cache_path, DIRECTORY_SEPARATOR)) {
$cache_path = substr($cache_path, 1);
}
// Si la préférence termine par un "/" alors l'enlever
if (endswith($cache_path, DIRECTORY_SEPARATOR)) {
$cache_path = substr($cache_path, -1, 1);
}
// Ajouter à la préférence le chemin complet
$config = $mod->GetConfig();
$cache_path = $config['root_path'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . $cache_path;
return $cache_path;
}
示例6: process_template
/**
* Process the specififed template through smarty.
* This method will attempt to find the current action module, and given that and the name of the template find the template contents.
* if the template name ends with .tpl a module file template is assumed. Otherwise, a module database template will be assumed.
* If a module cannot be determined, then a file template is assumed, using the 'file' smarty resource.
*
* @param string $tpl The name of the template to process.
*/
protected function process_template($tpl)
{
$smarty = cmsms()->GetSmarty();
$actionmodule = $smarty->get_template_vars('actionmodule');
if ($actionmodule) {
$mod = \cms_utils::get_module($actionmodule);
if (is_object($mod)) {
if (endswith($tpl, '.tpl')) {
$out = $mod->ProcessTemplate($tpl);
} else {
$out = $mod->ProcessTemplateFromDatabase($tpl);
}
}
} else {
$out = $smarty->fetch('file:' . $tpl);
}
return $out;
}
示例7: showFiles
function showFiles()
{
echo "<h2>Icons</h2>\n";
echo '<table border="1">';
$list = array();
$d = dir(".");
while (false !== ($entry = $d->read())) {
if (endswith($entry, ".gif") || endswith($entry, ".jpg") || endswith($entry, ".png")) {
$list[] = $entry;
}
}
$d->close();
sort($list);
foreach ($list as $entry) {
echo '<tr><td>' . $entry . ' </td><td bgcolor="#C0C0C0"><a href="' . $entry . '"><img src="' . $entry . '"></a></td>' . "\n";
}
echo "</table>\n";
}
示例8: sendAsHtml
function sendAsHtml()
{
global $filetype;
if ($handle = opendir('./')) {
/* This is the correct way to loop over the directory. */
$first = true;
$i = 1;
while (false !== ($file = readdir($handle))) {
if (endswith($file, $filetype)) {
if (!$first) {
echo ' - ';
} else {
$first = false;
}
echo "<a href=\"./{$file}\">Page {$i}</a> ";
$i++;
}
}
closedir($handle);
}
}
示例9: build
private function build($type,$id){
if(endswith($type,"s")){
$table = $type;
$name = substr($type,0,-1);
}else{
$table = $type."s";
$name = $type;
}
$rows = $this->db->get_where($table,array("element_id"=>$id));
if(rows($rows)){
$out = array();
foreach($rows->result_array() as $curRow){
$out[$curRow['id']] = new $name( $this->oh, $curRow['id']);
}
$this->objArrays[$table] = $out;
return $out;
}else
return array();
}
示例10: testAllCases
public function testAllCases()
{
$TEST_CASE_DIR = realpath(__DIR__ . '/cases');
echo "Directory is " . $TEST_CASE_DIR;
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($TEST_CASE_DIR));
foreach ($dir as $name => $object) {
if (!endswith($name, '.txt')) {
continue;
}
//$this->assertEquals($this->fmt->parseFile($name), file_get_contents($name . '.fixed'));
$lines1 = explode("\n", $this->fmt->parseFile($name));
$lines2 = explode("\n", file_get_contents($name . '.fixed'));
for ($l = 0; $l < count($lines1); $l++) {
if (!($lines1[$l] == $lines2[$l])) {
$first = $lines1[$l];
$second = $lines2[$l];
$this->assertTrue(false, "Line {$l} in file {$name} is incorrect\n" . "expected: {$second}\n" . "actual: {$first}");
}
$this->assertEquals($lines1[$l], $lines2[$l]);
}
}
}
示例11: is_valid_url
/**
* A utility function to test if the supplied url path is valid for the supplied content id
*
* @param string The partial url path to test
* @return boolean
*/
public static function is_valid_url($url, $content_id = '')
{
// check for starting or ending slashes
if (startswith($url, '/') || endswith($url, '/')) {
return FALSE;
}
// first check for invalid chars.
$translated = munge_string_to_url($url, false, true);
if (strtolower($translated) != strtolower($url)) {
return FALSE;
}
cms_route_manager::load_routes();
$route = cms_route_manager::find_match($url);
if (!$route) {
return TRUE;
}
if ($route->is_content()) {
if ($content_id == '' || $route->get_content() == $content_id) {
return TRUE;
}
}
return FALSE;
}
示例12: is_valid_url
/**
* A utility function to test if the supplied url path is valid for the supplied content id
*
* @param string The partial url path to test
* @return boolean
*/
public static function is_valid_url($url, $content_id = '')
{
// check for starting or ending slashes
if (startswith($url, '/') || endswith($url, '/')) {
return FALSE;
}
// first check for invalid chars.
// strip off any extension (that is like 5 chars or less)
$pos = strrpos($url, '.');
if ($pos !== FALSE) {
// have an extension.
$ext = substr($url, $pos + 1);
if (strlen($ext) >= 5 || munge_string_to_url($ext, false, true) != strtolower($ext)) {
return FALSE;
}
$tmp = substr($url, 0, $pos);
if (munge_string_to_url($tmp, false, true) != strtolower($tmp)) {
return FALSE;
}
} else {
$translated = munge_string_to_url($url, false, true);
if (strtolower($translated) != strtolower($url)) {
return FALSE;
}
}
cms_route_manager::load_routes();
$route = cms_route_manager::find_match($url, TRUE);
if (!$route) {
return TRUE;
}
if ($route->is_content()) {
if ($content_id == '' || $route->get_content() == $content_id) {
return TRUE;
}
}
return FALSE;
}
示例13: includeType
/**
* Ensure that a given type is actually included
*
* @param string $class
*/
public function includeType($class)
{
if (empty($class)) {
throw new Exception("Cannot include null type");
}
$class = str_replace('.', '_', $class);
$dir = 'model';
$file = $class . '.php';
$source = $dir . DIRECTORY_SEPARATOR . $file;
$found = false;
if (!Zend_Loader::isReadable($source)) {
$extensions = array_merge(array('november'), za()->getExtensions());
foreach ($extensions as $extDir) {
$source = $extDir . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . $file;
if (Zend_Loader::isReadable($source)) {
$found = true;
break;
}
}
} else {
$found = true;
}
if (!$found && endswith($class, 'Version')) {
// try including the non-version instance instead
return $this->includeType(substr($class, 0, strrpos($class, 'Version')));
}
try {
if (!class_exists($class, false)) {
Zend_Loader::loadFile(basename($source), APP_DIR . DIRECTORY_SEPARATOR . dirname($source), true);
}
} catch (Zend_Exception $ze) {
// ignore it, we'll just assume it was loaded elsewhere
}
if (!class_exists($class)) {
throw new Exception("Class {$class} not found in the model directory");
}
}
示例14: get_output
/**
* Get the output of the report.
*
* @return mixed the actual output format depends upon the template that is provided.
*/
public function get_output()
{
$out = null;
$data = parent::get_output();
if (!is_array($data)) {
return $out;
}
$smarty = cmsms()->GetSmarty();
$smarty->assign('report_data', $data);
$actionmodule = $smarty->get_template_vars('actionmodule');
if ($actionmodule) {
$mod = cms_utils::get_module($actionmodule);
if (is_object($mod)) {
if (endswith($this->get_template(), '.tpl')) {
$out = $mod->ProcessTemplate($this->get_template());
} else {
$out = $mod->ProcessTemplateFromDatabase($this->get_template());
}
}
} else {
$out = $smarty->fetch('file:' . $template);
}
return $out;
}
示例15: __construct
function __construct(&$content_obj, $params = array())
{
$params['block_type'] = 'date';
parent::__construct($content_obj, $params);
$showClock = !(isset($params['show_clock']) && ac_utils::IsFalse($params['show_clock']));
$mode = 'calendar';
if (isset($params['mode']) && strtolower($params['mode']) == 'dropdown') {
$mode = 'dropdown';
}
$show24h = !(isset($params['show24h']) && ac_utils::IsFalse($params['show24h']));
$dateFormat = isset($params['date_format']) ? $params['date_format'] : '%x %X';
$startHour = 0;
$endHour = 23;
if (isset($params['start_hour'])) {
if (endswith($params['start_hour'], 'pm')) {
$params['start_hour'] = trim(str_ireplace('pm', '', $params['start_hour'])) + 12;
} else {
$params['start_hour'] = trim(str_ireplace(array('am', 'pm'), '', $params['start_hour']));
}
if ($params['start_hour'] > 0 && $params['start_hour'] <= $endHour) {
$startHour = trim($params['start_hour']);
}
}
if (isset($params['end_hour'])) {
if (endswith($params['end_hour'], 'pm')) {
$params['end_hour'] = trim(str_ireplace('pm', '', $params['end_hour'])) + 12;
} else {
$params['end_hour'] = trim(str_ireplace(array('am', 'pm'), '', $params['end_hour']));
}
if ($params['end_hour'] >= 0 && $params['end_hour'] < $endHour) {
$endHour = trim($params['end_hour']);
}
}
if ($endHour < $startHour) {
$endHour = $startHour;
}
$startMinute = 0;
if (isset($params['start_minute']) && $params['start_minute'] > 0 && $params['start_minute'] <= 59) {
$startMinute = trim($params['start_minute']);
}
$endMinute = 59;
if (isset($params['end_minute']) && $params['end_minute'] >= 0 && $params['end_minute'] < 59) {
$endMinute = trim($params['end_minute']);
}
if ($endMinute < $startMinute) {
$endMinute = $startMinute;
}
$startSecond = 0;
if (isset($params['start_second']) && $params['start_second'] > 0 && $params['start_second'] <= 59) {
$startSecond = trim($params['start_second']);
}
$endSecond = 59;
if (isset($params['end_second']) && $params['end_second'] >= 0 && $params['end_second'] < 59) {
$endSecond = trim($params['end_second']);
}
if ($endSecond < $startSecond) {
$endSecond = $startSecond;
}
$stepHours = 1;
if (isset($params['step_hours']) && $params['step_hours'] > 0 && $params['step_hours'] <= $endHour - $startHour) {
$stepHours = trim($params['step_hours']);
} else {
if (isset($params['step_hours']) && $params['step_hours'] > 0 && $params['step_hours'] >= $endHour - $startHour) {
$stepHours = $endHour - $startHour;
}
}
$stepMinutes = 30;
if (isset($params['step_minutes']) && $params['step_minutes'] > 0 && $params['step_minutes'] <= $endMinute - $startMinute) {
$stepMinutes = trim($params['step_minutes']);
} else {
if (isset($params['step_minutes']) && $params['step_minutes'] > 0 && $params['step_minutes'] >= $endMinute - $startMinute) {
$stepMinutes = $endMinute - $startMinute;
}
}
$stepSeconds = 1;
if (isset($params['step_seconds']) && $params['step_seconds'] > 0 && $params['step_seconds'] <= $endSecond - $startSeconds) {
$stepSeconds = trim($params['step_seconds']);
} else {
if (isset($params['step_seconds']) && $params['step_seconds'] > 0 && $params['step_seconds'] >= $endSecond - $startSeconds) {
$stepSeconds = $endSecond - $startSeconds;
}
}
$this->SetProperty('show24h', $show24h);
$this->SetProperty('mode', $mode);
$this->SetProperty('start_hour', $startHour);
$this->SetProperty('end_hour', $endHour);
$this->SetProperty('start_minute', $startMinute);
$this->SetProperty('end_minute', $endMinute);
$this->SetProperty('start_second', $startSecond);
$this->SetProperty('end_second', $endSecond);
$this->SetProperty('step_hours', $stepHours);
$this->SetProperty('step_minutes', $stepMinutes);
$this->SetProperty('step_seconds', $stepSeconds);
$this->SetProperty('show_clock', $showClock);
$this->SetProperty('date_format', $dateFormat);
}