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


PHP count_letters函数代码示例

本文整理汇总了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 . '&nbsp;';
     /// 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));
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:23,代码来源:assignment.class.php

示例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');
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:file.php

示例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();
    }
开发者ID:e-rasvet,项目名称:mediaboard,代码行数:31,代码来源:mediaboard.class.php

示例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;
开发者ID:guylancaster999,项目名称:william2016,代码行数:31,代码来源:do_contact_e.php

示例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.'&paramone='. $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;
 }
开发者ID:laiello,项目名称:poodll.poodll23,代码行数:84,代码来源:assignment.class.php

示例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');
}
开发者ID:Anna-Sentyakova,项目名称:runningcat,代码行数:31,代码来源:file.php

示例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;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:29,代码来源:assignment.class.php

示例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';
开发者ID:jaynorth,项目名称:Euler-Project,代码行数:31,代码来源:Problem17.php

示例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
 }
开发者ID:laiello,项目名称:poodll,代码行数:81,代码来源:assignment.class.php


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