本文整理汇总了PHP中nl2br函数的典型用法代码示例。如果您正苦于以下问题:PHP nl2br函数的具体用法?PHP nl2br怎么用?PHP nl2br使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nl2br函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendemail
function sendemail()
{
if (isset($_POST['action']) and $_POST['action'] == 'send') {
$body = BODY;
if (!is_string($_POST['name']) or $_POST['name'] == '') {
return '<p class="error">Insert correct name</p>';
}
if (!is_email($_POST['email']) or $_POST['email'] == '') {
return '<p class="error">Insert correct email</p>';
}
$subject = $_POST['subject'];
if (!is_email($subject) or $subject == '') {
$subject = 'Email without subject.';
}
foreach (array_map('stripslashes', $_POST) as $id => $var) {
if ($id == 'message') {
$var = nl2br($var);
}
$body = str_replace("%{$id}%", $var, $body);
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "From: myplace@here.com\r\n";
$sendmail = mail(TO, $subject, $body, $headers);
if ($sendmail) {
return '<p class="success">Email sent correctly!</p>';
} else {
return '<p class="error">An error has been encountered. Please try again.</p>';
}
}
}
示例2: OnPreRender
function OnPreRender()
{
/* @var $o_season Season */
/* @var $o_team Team */
$this->SetCaption($this->o_competition->GetName());
$o_headings = new XhtmlRow(array('Name of team', 'Ground address', 'Contact details'));
$o_headings->SetIsHeader(true);
$this->AddRow($o_headings);
foreach ($this->o_competition->GetLatestSeason()->GetTeams() as $o_team) {
if ($o_team instanceof Team) {
$o_row = new XhtmlRow();
$o_row->AddCell(new XhtmlAnchor(Html::Encode($o_team->GetName()), $o_team->GetEditTeamUrl()));
$o_row->AddCell(new PostalAddressControl($o_team->GetGround()->GetAddress()));
$private = $o_team->GetPrivateContact();
$public = $o_team->GetContact();
$private_header = '<h2 style="margin:0; font-size:1.1em; color: #900;">Private</h2>';
if ($private and $public) {
$contact = $public . $private_header . $private;
} else {
$contact = $private ? $private_header . $private : $public;
}
$o_row->AddCell(nl2br(XhtmlMarkup::ApplySimpleTags(XhtmlMarkup::ApplyLinks($contact, true))));
$this->AddRow($o_row);
}
}
parent::OnPreRender();
}
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:27,代码来源:competition-text-table.class.php
示例3: rex_setup_import
function rex_setup_import($import_sql, $import_archiv = null)
{
global $REX, $I18N, $export_addon_dir;
$err_msg = '';
if (!is_dir($export_addon_dir)) {
$err_msg .= $I18N->msg('setup_03703') . '<br />';
} else {
if (file_exists($import_sql) && ($import_archiv === null || $import_archiv !== null && file_exists($import_archiv))) {
// Hier I18N_IM_EXPORT global definieren, damit es aus der config.inc.php übernommen
// wird und auch in der danach includeten function verfügbar ist
global $I18N_IM_EXPORT;
require $export_addon_dir . '/config.inc.php';
require_once $export_addon_dir . '/classes/class.tar.inc.php';
require_once $export_addon_dir . '/classes/class.rex_tar.inc.php';
require_once $export_addon_dir . '/functions/function_folder.inc.php';
require_once $export_addon_dir . '/functions/function_import_export.inc.php';
// DB Import
$state_db = rex_a1_import_db($import_sql);
if ($state_db['state'] === false) {
$err_msg .= nl2br($state_db['message']) . '<br />';
}
// Archiv optional importieren
if ($state_db['state'] === true && $import_archiv !== null) {
$state_archiv = rex_a1_import_files($import_archiv);
if ($state_archiv['state'] === false) {
$err_msg .= $state_archiv['message'] . '<br />';
}
}
} else {
$err_msg .= $I18N->msg('setup_03702') . '<br />';
}
}
return $err_msg;
}
示例4: __construct
public function __construct()
{
$this->name = 'bankwire';
$this->tab = 'payments_gateways';
$this->version = '1.0.8';
$this->author = 'PrestaShop';
$this->controllers = array('payment', 'validation');
$this->is_eu_compatible = 1;
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$config = Configuration::getMultiple(array('BANK_WIRE_DETAILS', 'BANK_WIRE_OWNER', 'BANK_WIRE_ADDRESS'));
if (!empty($config['BANK_WIRE_OWNER'])) {
$this->owner = $config['BANK_WIRE_OWNER'];
}
if (!empty($config['BANK_WIRE_DETAILS'])) {
$this->details = $config['BANK_WIRE_DETAILS'];
}
if (!empty($config['BANK_WIRE_ADDRESS'])) {
$this->address = $config['BANK_WIRE_ADDRESS'];
}
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Bank wire');
$this->description = $this->l('Accept payments for your products via bank wire transfer.');
$this->confirmUninstall = $this->l('Are you sure about removing these details?');
if (!isset($this->owner) || !isset($this->details) || !isset($this->address)) {
$this->warning = $this->l('Account owner and account details must be configured before using this module.');
}
if (!count(Currency::checkPaymentCurrencies($this->id))) {
$this->warning = $this->l('No currency has been set for this module.');
}
$this->extra_mail_vars = array('{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')), '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')));
}
示例5: show_list
/**
*
*/
function show_list()
{
global $_GET;
if ($_GET['phrase']) {
$where .= sprintf('AND proverb LIKE \'%%%1$s%%\' ', $this->db->quote($_GET['phrase'], null, false));
}
$cols = 'proverb, meaning';
$from = 'FROM proverb WHERE prv_type = 1 ' . $where . 'ORDER BY proverb ASC';
$rows = $this->db->get_rows_paged($cols, $from);
if ($this->db->num_rows > 0) {
$ret .= '<p>' . $this->db->get_page_nav() . '</p>' . LF;
$ret .= '<dl>';
foreach ($rows as $row) {
$ret .= '<dt>' . $row['proverb'] . '</dt>' . LF;
$ret .= '<dd>' . LF;
$ret .= nl2br(strip_tags($row['meaning'])) . LF;
$ret .= '</dd>' . LF;
}
$ret .= '</dl>' . LF;
$ret .= '<p>' . $this->db->get_page_nav() . '</p>' . LF;
} else {
$ret .= '<p>' . $this->msg['na'] . '</p>' . LF;
}
return $ret;
}
示例6: feed
static function feed($feed_id, $offset, $limit, $id)
{
$feed = new stdClass();
switch ($feed_id) {
case "latest":
$feed->items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC")->find_all($limit, $offset);
$all_items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC");
$feed->max_pages = ceil($all_items->find_all()->count() / $limit);
$feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
$feed->description = t("Recent updates");
return $feed;
case "album":
$item = ORM::factory("item", $id);
access::required("view", $item);
$feed->items = $item->viewable()->descendants($limit, $offset, array(array("type", "=", "photo")));
$feed->max_pages = ceil($item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
if ($item->id == item::root()->id) {
$feed->title = html::purify($item->title);
} else {
$feed->title = t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title));
}
$feed->description = nl2br(html::purify($item->description));
return $feed;
}
}
示例7: getStatusMessage
public function getStatusMessage()
{
$statusMessage = '';
$this->checkForDbUpdate($this->extension->getExtensionKey(), $this->extension->getExtensionDir() . 'ext_tables.sql');
if ($this->dbUpdateNeeded) {
$statusMessage .= '<p>Database has to be updated!</p>';
$typeInfo = array('add' => 'Add fields', 'change' => 'Change fields', 'create_table' => 'Create tables');
$statusMessage .= '<div id="dbUpdateStatementsWrapper"><table>';
foreach ($this->updateStatements as $type => $statements) {
$statusMessage .= '<tr><td></td><td style="text-align:left;padding-left:15px">' . $typeInfo[$type] . ':</td></tr>';
foreach ($statements as $key => $statement) {
if ($type == 'add') {
$statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px">' . $statement . '</td></tr>';
} elseif ($type === 'change') {
$statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px">' . $statement . '</td></tr>';
$statusMessage .= '<tr><td></td><td style="text-align:left;padding-left:15px">Current value: ' . $this->updateStatements['change_currentValue'][$key] . '</td></tr>';
} elseif ($type === 'create_table') {
$statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px;">' . nl2br($statement) . '</td></tr>';
}
}
}
$statusMessage .= '</table></div>';
}
if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($this->extension->getExtensionKey())) {
$statusMessage .= '<p>Your Extension is not installed yet.</p>';
}
return $statusMessage;
}
示例8: envia
public function envia()
{
$this->load->model('email_model');
$this->load->model('usuarios_model');
$this->load->library('functions');
$email = $this->input->post('email');
$usuario = $this->usuarios_model->getByEmail($email);
if ($usuario != NULL) {
if ($usuario['status'] == 1) {
$mensagem = nl2br("<strong>Olá " . ($usuario['nome_aluno'] != NULL ? $usuario['nome_aluno'] : $usuario['nome_responsavel']) . "!</strong> \n\t\t\tFoi solicitado, através do seu e-mail, uma NOVA SENHA pela <u><strong>Área Exclusiva</strong> do Programa Jovem Trabalhador</u>.\n\t\t\t" . ($usuario['nome_aluno'] != NULL ? $usuario['nome_aluno'] : $usuario['nome_responsavel']) . ", você está ciente disto?\n\t\t\t<a href='" . base_url('areaexclusiva/redefinir/' . $usuario['id_usuario'] . '/' . urlencode($usuario['redefinicao'])) . "'>SIM! EU QUERO REDEFINIR A SENHA DA MINHA ÁREA EXCLUSIVA!</a>\n\n\t\t\tCaso não tenha sido você quem solicitou, por favor, <u>nos avise clicando no link abaixo:</u>\n\t\t\t<a href='" . base_url('areaexclusiva/cancelar_redef/' . $usuario['id_usuario']) . "'>NÃO SOLICITEI REDEFINIÇÃO DE SENHA!</a>");
$this->load->helper('email');
$this->load->model("email_model");
$this->email_model->EnviarEmail("noreplay@programajovemtrabalhador.com.br", "Suporte Programa Jovem Trabalhador", $usuario['email_aluno'] != NULL ? $usuario['email_aluno'] : $usuario['email_responsavel'], "Redefinição de senha", $mensagem);
$this->session->set_flashdata("alert", "Foi enviado um email para você com os dados para a redefinição de senha !");
redirect("areaexclusiva/");
} else {
if ($usuario['status'] == 2) {
$this->session->set_flashdata("error", "O seu cadastro não foi aprovado por um de nossos colaboradores !");
redirect("areaexclusiva/login/recover");
} else {
$this->session->set_flashdata("error", "Aguarde a aprovação do seu cadastro por um de nossos colaboradores !");
redirect("areaexclusiva/login/recover");
}
}
} else {
$this->session->set_flashdata("error", "E-mail não cadastrado na área exclusiva !");
redirect("areaexclusiva/login/recover");
}
}
示例9: renderTextAsHtml
public function renderTextAsHtml($content)
{
$content = preg_replace('|(<\\/[^>]+>)\\r?\\n|', '$1', $content);
$content = preg_replace('|[\\r\\n]+(<!--)|', '$1', $content);
$content = preg_replace('|(-->)[\\r\\n]+|', '$1', $content);
return nl2br($content);
}
示例10: index
public function index()
{
$id = $this->_get('id', 'intval');
$token = $this->token;
$bid = M('Lottery')->where(array('id' => $id, 'token' => $token))->getField('zjpic');
if (!$bid) {
$this->error('不存在的活动');
}
$Activity = M('Activity')->where(array('id' => $bid, 'token' => $token, 'type' => 1))->find();
if (!$Activity) {
$this->error('不存在的活动');
}
if (time() < $Activity['statdate']) {
$this->error('活动未开始,请在' . date('Y-m-d H:i:s', $Activity['statdate']) . '后再来参加活动!');
}
if ($Activity['enddate'] < time()) {
$this->error('活动已结束');
}
if ($Activity['status'] == 0) {
$this->error('活动已结束');
}
$wecha_id = $this->wecha_id;
$count = M('Activity')->where(array('token' => $token, 'id' => $bid))->getField('joinnum');
$list = M('Autumns_box')->where(array('token' => $token, 'wecha_id' => $wecha_id, 'bid' => $id))->select();
$prize = M('Autumns_box')->where(array('isprize' => 1, 'token' => $token, 'bid' => $id))->select();
$nums = $Activity['fistnums'] + $Activity['secondnums'] + $Activity['thirdnums'] + $Activity['fournums'] + $Activity['fivenums'] + $Activity['sixnums'];
$lucknums = $Activity['fistlucknums'] + $Activity['secondlucknums'] + $Activity['thirdlucknums'] + $Activity['fourlucknums'] + $Activity['fivelucknums'] + $Activity['sixlucknums'];
$displayjpnums = $Activity['displayjpnums'];
$data = $Activity;
$fans = $this->fans;
$data['info'] = nl2br($data['info']);
$data['aginfo'] = nl2br($data['aginfo']);
$data['endinfo'] = nl2br($data['endinfo']);
$data['info'] = str_replace('<br>', '<br>', $data['info']);
$data['aginfo'] = str_replace('<br>', '<br>', $data['aginfo']);
$data['endinfo'] = str_replace('<br>', '<br>', $data['endinfo']);
$url = M('Home')->where(array('token' => $token))->getField('gzhurl');
$focus = $Activity['focus'];
$weixin = $this->wxuser['weixin'];
$this->assign('fans', $fans);
$this->assign('weixin', $weixin);
$this->assign('focus', $focus);
$this->assign('url', $url);
$this->assign('activity', $data);
$this->assign('displayjpnums', $displayjpnums);
$this->assign('nums', $nums);
$this->assign('lucknums', $lucknums);
$this->assign('linfo', $Activity);
$this->assign('count', $count);
$this->assign('list', $list);
$this->assign('prize', $prize);
if ($Activity['focus'] == 1 && $this->isSubscribe() == false) {
$this->memberNotice('', 1);
} else {
if ($Activity['needreg'] == 0 && empty($this->fans['tel'])) {
$this->memberNotice();
}
}
$this->display();
}
示例11: vam_db_error
function vam_db_error($query, $errno, $error)
{
// BOF db-error processing
include DIR_WS_LANGUAGES . 'russian/russian_db_error.php';
$msg = "\n" . 'MYSQL ERROR REPORT' . "\n" . " - " . date("d/m/Y H:m:s", time()) . "\n" . '---------------------------------------' . "\n";
$msg .= $errno . ' - ' . $error . "\n\n" . $query . "\n";
$msg .= '---------------------------------------' . "\n";
$msg .= 'Server Name : ' . $_SERVER['SERVER_NAME'] . "\n";
$msg .= 'Remote Address: ' . $_SERVER['REMOTE_ADDR'] . "\n";
$msg .= 'Referer : ' . $_SERVER["HTTP_REFERER"] . "\n";
$msg .= 'Requested : ' . $_SERVER["REQUEST_URI"] . "\n";
$msg .= 'Trace Back : ' . str_replace(DIR_FS_CATALOG, '', str_replace('\\', '/', implode(" => ", zen_trace_back('', 0, 1, true)))) . "\n";
if (defined('DEBUG') && DEBUG == true) {
echo nl2br($msg);
die('==========================================================================');
}
$log = date("d/m/Y H:m:s", time()) . ' | ' . $errno . ' - ' . $error . ' | ' . $query . ' | ' . $_SERVER["REQUEST_URI"] . "\n";
// echo "<br>".$query."<br>".$error."<br>";
error_log($log, 3, 'mysql_db_error.log');
mail(DB_ERR_MAIL, 'MySQL DB Error!', $msg, 'From: db_error@' . $_SERVER["SERVER_NAME"]);
if (!headers_sent() && file_exists('db_error.htm')) {
header('Location: db_error.htm');
//include('db_error.htm');
}
die(DB_ERR_MSG);
}
示例12: _highlighter
/**
* Функция перенесена из функции addElementsForm() из-за возникающей ошибки:
* Cannot redeclare highlighter() (previously declared in
* application\models\Form\Test\Testing.php:41) in
* application\models\Form\Test\Testing.php on line 41
* @param unknown_type $text
* @param unknown_type $classExistsTH
*/
private function _highlighter($text, $classExistsTH = false)
{
$text = str_replace('[js]', '[javascript]', $text);
$text = str_replace('[/js]', '[/javascript]', $text);
$text = str_replace(array('[code lang="js"]', '[code lang=\'js\']'), '[code lang="javascript"]', $text);
$tags = '(?:php)|(?:sql)|(?:css)|(?:javascript)|(?:html)|(?:sh)';
if ($classExistsTH) {
$text .= '[code lang=""][/code]';
// заменяет все теги на [code lang="langName"] и [/code]
$text = preg_replace('/\\[(' . $tags . ')\\](.*?)\\[\\/(?:' . $tags . ')\\]/is', "[code lang='\$1']\$2[/code]", $text);
//розбтвает строку и записывает в массив
preg_match_all("/(.*?)\\[code lang=['\"](.*?)['\"]\\](.*?)\\[\\/code\\]/is", $text, $matches);
$text = '';
$count = count($matches[0]);
for ($i = 0; $i < $count; $i++) {
$text .= nl2br(htmlspecialchars($matches[1][$i]));
if ($matches[2][$i]) {
$hl =& Text_Highlighter::factory($matches[2][$i]);
$text .= $hl->highlight($matches[3][$i]);
}
}
} else {
$text = htmlspecialchars($text);
$text = preg_replace('/(\\[code lang=.*?\\])/is', '<pre>', $text);
$text = str_replace(array('[php]', '[sql]', '[css]', '[js]', '[html]', '[bash]'), '<pre>', $text);
$text = str_replace(array('[/php]', '[/sql]', '[/css]', '[/js]', '[/html]', '[/bash]', '[/code]'), '</pre>', $text);
//$text = nl2br($text);
$text = str_replace("\r\n", '<br/>', $text);
}
return $text;
}
示例13: comment_mail_notification
public function comment_mail_notification()
{
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->SMTPAuth = SMTP_AUTH;
$mail->Username = SMTP_USER;
$mail->Password = SMTP_PASS;
$mail->SMTPSecure = SMTP_SECURE;
$mail->Port = SMTP_PORT;
$mail->From = SMTP_FROM;
$mail->FromName = SMTP_FROM_NAME;
$mail->addReplyTo(SMTP_REPLY_TO, SMTP_REPLY_TO_NAME);
$mail->addAddress(SMTP_TO, SMTP_TO_NAME);
$mail->isHTML(SMTP_ISHTML);
$mail->Subject = SMTP_SUBJECT . strftime("%T", time());
$created = datetime_to_text($this->created);
$mail_body = nl2br($this->body);
$photo = Photograph::find_by_id($_GET['id']);
$mail->Body = <<<EMAILBODY
A new comment has been received in the Photo Gallery.<br>
<br>
Photograph: {$photo->filename}<br>
<br>
On {$created}, {$this->author} wrote:<br>
<br>
{$mail_body}<br>
EMAILBODY;
$result = $mail->send();
return $result;
}
示例14: doChangePassword
/**
* @param array $data
* @return SS_HTTPResponse|void
*/
function doChangePassword(array $data)
{
try {
$token = Session::get('AutoLoginHash');
$member = $this->password_manager->changePassword($token, @$data['NewPassword1'], @$data['NewPassword2']);
Session::clear('AutoLoginHash');
$back_url = isset($_REQUEST['BackURL']) ? $_REQUEST['BackURL'] : '/';
return OpenStackIdCommon::loginMember($member, $back_url);
} catch (InvalidResetPasswordTokenException $ex1) {
Session::clear('AutoLoginHash');
Controller::curr()->redirect('login');
} catch (EmptyPasswordException $ex2) {
$this->clearMessage();
$this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
Controller::curr()->redirectBack();
} catch (PasswordMismatchException $ex3) {
$this->clearMessage();
$this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
Controller::curr()->redirectBack();
} catch (InvalidPasswordException $ex4) {
$this->clearMessage();
$this->sessionMessage(sprintf(_t('Member.INVALIDNEWPASSWORD', "We couldn't accept that password: %s"), nl2br("\n" . $ex4->getMessage())), "bad");
Controller::curr()->redirectBack();
}
}
示例15: index
public function index()
{
$this->template->registerMeta("ROBOTS", "NOINDEX, NOFOLLOW");
$this->core->set_meta_tags(lang('Feedback', 'feedback'));
$this->load->library('form_validation');
// Create captcha
$this->dx_auth->captcha();
$tpl_data['cap_image'] = $this->dx_auth->get_captcha_image();
$this->template->add_array($tpl_data);
if (count($_POST) > 0) {
$this->form_validation->set_rules('name', lang('Your name', 'feedback'), 'trim|required|min_length[3]|max_length[' . $this->username_max_len . ']|xss_clean');
$this->form_validation->set_rules('email', lang('Email', 'feedback'), 'trim|required|valid_email|xss_clean');
$this->form_validation->set_rules('theme', lang('Subject', 'feedback'), 'trim|required|max_length[' . $this->theme_max_len . ']|xss_clean');
$this->form_validation->set_rules('message', lang('Message', 'feedback'), 'trim|required|max_length[' . $this->message_max_len . ']|xss_clean');
if ($this->dx_auth->use_recaptcha) {
$this->form_validation->set_rules('recaptcha_response_field', lang("Protection code", 'feedback'), 'trim|xss_clean|required|callback_recaptcha_check');
} else {
$this->form_validation->set_rules('captcha', lang("Protection code", 'feedback'), 'trim|required|xss_clean|callback_captcha_check');
}
if ($this->form_validation->run($this) == FALSE) {
// there are errors
$this->form_validation->set_error_delimiters("", "");
CMSFactory\assetManager::create()->setData('validation', $this->form_validation);
} else {
// form is validate
$this->message = strip_tags(nl2br(lang('Theme', 'feedback') . ' : ' . $this->input->post('theme') . lang('Name', 'feedback') . ' : ' . $this->input->post('name') . lang('E-mail', 'feedback') . ' : ' . $this->input->post('email') . lang('Message', 'feedback') . ' : ' . $this->input->post('message')));
$this->_send_message();
}
}
CMSFactory\assetManager::create()->render('feedback');
}