本文整理汇总了PHP中count_letters函数的典型用法代码示例。如果您正苦于以下问题:PHP count_letters函数的具体用法?PHP count_letters怎么用?PHP count_letters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了count_letters函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_user_files
function print_user_files($userid, $return = false)
{
global $OUTPUT, $CFG;
if (!($submission = $this->get_submission($userid))) {
return '';
}
$link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
$action = new popup_action('click', $link, 'file' . $userid, array('height' => 450, 'width' => 580));
$popup = $OUTPUT->action_link($link, get_string('popupinnewwindow', 'assignment'), $action, array('title' => get_string('submission', 'assignment')));
$output = '<div class="files">' . '<img align="middle" src="' . $OUTPUT->pix_url('f/html') . '" height="16" width="16" alt="html" />' . $popup . '</div>';
$wordcount = '<p id="wordcount">' . $popup . ' ';
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
$wordcount .= '(' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
$wordcount .= '(' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')';
}
}
$wordcount .= '</p>';
$text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
return $wordcount . format_text($text, $submission->data2, array('overflowdiv' => true));
}
示例2: print_error
}
if ($assignment->assignmenttype != 'online') {
print_error('invalidtype', 'assignment');
}
$assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
if ($submission = $assignmentinstance->get_submission($user->id)) {
print_header(fullname($user, true) . ': ' . $assignment->name);
echo $OUTPUT->box_start('generalbox boxaligcenter', 'dates');
echo '<table>';
if ($assignment->timedue) {
echo '<tr><td class="c0">' . get_string('duedate', 'assignment') . ':</td>';
echo ' <td class="c1">' . userdate($assignment->timedue) . '</td></tr>';
}
echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>';
echo ' <td class="c1">' . userdate($submission->timemodified);
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')</td></tr>';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')</td></tr>';
}
}
echo '</table>';
echo $OUTPUT->box_end();
echo $OUTPUT->box(format_text($submission->data1, $submission->data2), 'generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
} else {
print_string('emptysubmission', 'assignment');
}
示例3: view_dates
function view_dates() {
global $USER, $CFG, $OUTPUT;
if (!$this->mediaboard->timeavailable && !$this->mediaboard->timedue) {
return;
}
echo $OUTPUT->box_start('generalbox boxaligncenter', 'dates');
echo '<table>';
if ($this->mediaboard->timeavailable) {
echo '<tr><td class="c0">'.get_string('availabledate','mediaboard').':</td>';
echo ' <td class="c1">'.userdate($this->mediaboard->timeavailable).'</td></tr>';
}
if ($this->mediaboard->timedue) {
echo '<tr><td class="c0">'.get_string('duedate','mediaboard').':</td>';
echo ' <td class="c1">'.userdate($this->mediaboard->timedue).'</td></tr>';
}
$submission = $this->get_submission($USER->id);
if ($submission) {
echo '<tr><td class="c0">'.get_string('lastedited').':</td>';
echo ' <td class="c1">'.userdate($submission->timemodified);
/// Decide what to count
if ($CFG->mediaboard_itemstocount == mediaboard_COUNT_WORDS) {
echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>';
} else if ($CFG->mediaboard_itemstocount == mediaboard_COUNT_LETTERS) {
echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')</td></tr>';
}
}
echo '</table>';
echo $OUTPUT->box_end();
}
示例4: trim
<?php
require "funcz/functionz.php";
$er = "";
$sname = $_POST["sname"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$subject = $_POST["subject"];
$message = trim($_POST["message"]);
if (count_letters($sname) < 2) {
$er .= " *Short-name* ";
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$er .= " *Invalid-email* ";
}
if (strlen($subject) < 2) {
$er .= " *Subject-Required*";
}
if (strlen($message) == 0) {
$er .= " *Message-Required* ";
} elseif (strlen($message) < 5) {
$er .= " *Longer Message Required* ";
}
if (count_digits($phone) < 7) {
$er .= " *Valid-Phone-number-Required* ";
}
if (strlen($er) > 0) {
$link = 'Location: kontakt_e.php';
$link .= "?error=Error-" . $er;
$link .= "&sname=" . $sname;
$link .= "&subject=" . $subject;
示例5: fetchResponses
function fetchResponses($contextid, $submissionid, $submissiontype, $submissiontext, $submissionfile, $checkfordata = false, $embed = false, $countwords = false)
{
global $CFG;
$responsestring = "";
//if we are showing a list of files we want to use text links not players
//a whole page of players will crash a browser.
//modify Justin 20120525 lists of flowplayers/jw players will break if embedded and
// flowplayers should have image link load deferral anyway
if ($CFG->filter_poodll_defaultplayer == 'pd' && $embed == 'true') {
//if($embed){
$embed = 'true';
$embedstring = get_string('clicktoplay', 'assignment_poodllonline');
} else {
$embedstring = 'clicktoplay';
$embed = 'false';
}
//if this is a playback area, for teacher, show a string if no file
if ($checkfordata && empty($submissionfile) && $submissiontype != OM_REPLYTEXTONLY) {
$responsestring .= "Nothing to play";
} else {
//The path to any media file we should play
//temporatily used custom logic because of a strange moodle bug that only i noticed. should be ok in 2,3 though
//so i reverted to standard pluginfile.php Justin 20120626
//20120802 removed the forcedownload because not necessary and also was causing parsing difficulty in poodllresourcelib.php fetchVideoSplash method
$mediapath = $CFG->wwwroot . '/pluginfile.php' . '/' . $contextid . '/mod_assignment/submission/' . $submissionid . '/' . $submissionfile;
//$mediapath = $CFG->wwwroot.'/pluginfile.php' . '/'.$contextid.'/mod_assignment/submission/'.$submissionid.'/'. $submissionfile . '?forcedownload=1';
//$mediapath = $CFG->wwwroot.'/filter/poodll/poodllfilelib.php?datatype=poodllpluginfile&contextid='. $contextid .'&itemid='.$submissionid.'¶mone='. $submissionfile;
$mediapath = urlencode($mediapath);
//check if we need media output
switch ($submissiontype) {
case OM_REPLYVOICEONLY:
case OM_REPLYMP3VOICE:
$responsestring .= format_text('{POODLL:type=audio,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML);
break;
case OM_REPLYVIDEOONLY:
$responsestring .= format_text('{POODLL:type=video,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML);
break;
case OM_REPLYVOICETHENTEXT:
$responsestring .= format_text('{POODLL:type=audio,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML);
break;
case OM_REPLYVIDEOTHENTEXT:
$responsestring .= format_text('{POODLL:type=video,path=' . $mediapath . ',protocol=http,embed=' . $embed . ',embedstring=' . $embedstring . '}', FORMAT_HTML);
break;
case OM_REPLYWHITEBOARD:
$responsestring .= "<img alt=\"submittedimage\" src=\"" . urldecode($mediapath) . "\" />";
break;
}
//end of switch
}
//end of if (checkfordata ...)
//check if we need text output
switch ($submissiontype) {
case OM_REPLYVIDEOONLY:
case OM_REPLYVOICEONLY:
case OM_REPLYWHITEBOARD:
case OM_REPLYMP3VOICE:
break;
case OM_REPLYVOICETHENTEXT:
case OM_REPLYVIDEOTHENTEXT:
//add a clear line if we have text after audio or video player
if (empty($submissiontext)) {
break;
} else {
$responsestring .= "<br />";
}
case OM_REPLYTEXTONLY:
default:
//if we are coming from print user files we also print the word count.
if ($countwords) {
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
$responsestring .= ' (' . get_string('numwords', '', count_words(format_text($submissiontext, FORMAT_HTML))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
$responsestring .= ' (' . get_string('numletters', '', count_letters(format_text($submissiontext, FORMAT_HTML))) . ')';
}
}
}
//finally we print the text response
$responsestring .= format_text($submissiontext, FORMAT_HTML);
}
//end of switch
return $responsestring;
}
示例6: require_login
}
require_login($course->id, false, $cm);
if ($USER->id != $user->id && !has_capability('mod/problemstatement:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
error("You can not view this problemstatement");
}
$problemstatementinstance = new problemstatement($cm->id, $problemstatement, $cm, $course);
if ($submission = $problemstatementinstance->get_submission($user->id)) {
print_header(fullname($user, true) . ': ' . $problemstatement->name);
print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
echo '<table>';
if ($problemstatement->timedue) {
echo '<tr><td class="c0">' . get_string('duedate', 'problemstatement') . ':</td>';
echo ' <td class="c1">' . userdate($problemstatement->timedue) . '</td></tr>';
}
echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>';
echo ' <td class="c1">' . userdate($submission->timemodified);
/// Decide what to count
//if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words($submission->programtext)) . ')</td></tr>';
//} else if ($CFG->problemstatement_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters($submission->programtext)) . ')</td></tr>';
//}
echo '</table>';
print_simple_box_end();
print_simple_box(highlight_syntax($submission->programtext, $submission->langid), 'center', '100%');
print_simple_box(format_text($submission->submissioncomment, 0), 'center', '100%');
close_window_button();
print_footer('none');
} else {
print_string('emptysubmission', 'problemstatement');
}
示例7: print_user_files
function print_user_files($userid, $return = false)
{
global $OUTPUT;
if (!($submission = $this->get_submission($userid))) {
return '';
}
$link = html_link::make("/mod/assignment/type/online/file.php?id={$this->cm}->id&userid={$submission->userid}", shorten_text(trim(strip_tags(format_text($submission->data1, $submission->data2))), 15));
$link->add_action(new popup_action('click', $link->url, 'file' . $userid, array('height' => 450, 'width' => 580)));
$link->title = get_string('submission', 'assignment');
$popup = $OUTPUT->link($link);
$output = '<div class="files">' . '<img align="middle" src="' . $OUTPUT->old_icon_url('f/html') . '" height="16" width="16" alt="html" />' . $popup . '</div>';
///Stolen code from file.php
echo $OUTPUT->box_start('generalbox boxaligncenter', 'wordcount');
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))) . ')';
}
}
echo $OUTPUT->box_end();
echo $OUTPUT->box(format_text($submission->data1, $submission->data2), 'generalbox boxaligncenter boxwidthwide');
///End of stolen code from file.php
if ($return) {
//return $output;
}
//echo $output;
}
示例8: strlen
echo " and ";
if ($dozen != 0) {
$sum += strlen($letters[$dozen]);
echo " {$letters[$dozen]}";
}
if ($digit != 0) {
$sum += strlen($letters[$digit]);
echo "{$letters[$digit]} <br />";
}
} elseif ($n == 1000) {
echo "one thousand";
$sum = 11;
} else {
echo "Not a valid number !!!";
}
return $sum;
}
$total = 0;
for ($i = 1; $i < 1001; $i++) {
$sum = count_letters($i);
$total += $sum;
}
echo "<br /><b>Total is {$total}<b>";
//////////////////////////////////////////////////////////////////////
// End of execution time calculation
$time_end = microtime(true);
$execution_time = $time_end - $time_start;
//total execution time
/////////////////////////////////////////////////////////////////////
//Below Outputs the execution time in seconds
echo '<br /><br /><b>Total Execution Time:</b> ' . $execution_time . ' seconds';
示例9: print_user_files
function print_user_files($userid, $return = false)
{
global $CFG;
if (!($submission = $this->get_submission($userid))) {
return '';
}
//Output user input Audio and Text, depending on assignment type.
switch ($this->assignment->var3) {
case OM_REPLYVOICEONLY:
if (!empty($submission->data2)) {
//print_simple_box(format_text('{FMS:VOICE='. $submission->data2.'}', FORMAT_HTML), 'center', '100%');
print_simple_box(format_text('{POODLL:type=audio,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%');
} else {
echo "No Audio Found.";
}
break;
case OM_REPLYVIDEOONLY:
if (!empty($submission->data2)) {
//print_simple_box(format_text('{FMS:VIDEO='. $submission->data2.'}', FORMAT_HTML), 'center', '100%');
print_simple_box(format_text('{POODLL:type=video,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%');
} else {
echo "No Video Found.";
}
break;
case OM_REPLYVOICETHENTEXT:
if (!empty($submission->data2)) {
//print_simple_box(format_text('{FMS:VOICE='. $submission->data2.'}', FORMAT_HTML), 'center', '100%');
print_simple_box(format_text('{POODLL:type=audio,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%');
print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount');
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')';
}
}
print_simple_box_end();
//print text
print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%');
} else {
echo "No Audio Found.";
}
break;
case OM_REPLYVIDEOTHENTEXT:
if (!empty($submission->data2)) {
//print_simple_box(format_text('{FMS:VIDEO='. $submission->data2.'}', FORMAT_HTML), 'center', '100%');
print_simple_box(format_text('{POODLL:type=video,path=' . $submission->data2 . ',protocol=rtmp}', FORMAT_HTML), 'center', '100%');
print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount');
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')';
}
}
print_simple_box_end();
//print text
print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%');
} else {
echo "No Video Found.";
}
break;
case OM_REPLYTEXTONLY:
default:
print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount');
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
echo ' (' . get_string('numwords', '', count_words(format_text($submission->data1, FORMAT_HTML))) . ')';
} else {
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
echo ' (' . get_string('numletters', '', count_letters(format_text($submission->data1, FORMAT_HTML))) . ')';
}
}
print_simple_box_end();
//print text
print_simple_box(format_text($submission->data1, FORMAT_HTML), 'center', '100%');
}
//end of text and audio output switch
}