搜索
首页后端开发php教程火车头discuz6.1 完美采集的php接口文件_php技巧

PS:对原文件的修改较大,程序中注释已经很详尽,这里就不多说了。

复制代码 代码如下:

// header('Content-Type:text/html;charset=UTF-8');
//if(function_exists("mb_convert_encoding")){
// $tmp = checkAndTranslate("使用前请将该文件直接上传至论坛根目录", 0);
// header('Content-Type:text/html;charset=UTF-8');
// print($tmp);
//}else{
// print("NO");
//}
// exit("this.line=".__line__);
/*
文件名:locoyonline_for_discuz610.php
*使用前请将该文件直接上传至论坛根目录
*本文件为GBK编码;
*处理后导入数据库的编码为:utf-8;
*需要替换字符时,需把replace.txt复制到同目录下;
*/
//处理全局变量
//foreach($_POST as $key => $value){
//$$key = $value ;
//print($key.' = '.$value.'n');
//}
//var_dump($_POST);
//exit('end-0');
// 需要插入的数据表
// 1.cdb_threads
// 2.cdb_rewardlog // ok 悬赏记录表
// 3.cdb_mythreads
// 4.cdb_posts
// 5.cdb_tags _update
// 6.cdb_threadtags
// 7.cdb_forums _update
// 8.cdb_members _update ok 更改悬赏表
//done end !
$user_list = file('./makeuser/username.txt');
// 随机发帖的用户名单,必须是已经注册的
// 关于批量注册用户名可以参考 Discuz 6.0 批量注册用户名
$user_list = array_map("curlAndCopy", $user_list);
function curlAndCopy($a){
return trim($a);
}
$replyusers = implode("|",$user_list);
//处理回复的格式
function trimAndCurl($str){
$str = preg_replace('/ns{5,}/','', $str , 1);
$str = trim($str);
$str = checkAndTranslate($str);
return $str;
}
function checkAndTranslate($mess, $if_replace =1, $in_char_type='GBK', $out_char_type='UTF-8'){
//if replace ?
if($if_replace){
$mess = curlAndReplace($mess);
}
//if chinese GBK ?
if(preg_match('/[x80-xff]./', $mess) ){
$mess = mb_convert_encoding($mess, $out_char_type, $in_char_type);
}
return addslashes($mess) ;
}
function curlAndReplace($message){
$replace_list = file('./makeuser/replace.txt');
foreach($replace_list as $item){
$item = preg_replace("/s /","||",$item);
$items = explode("||",$item);
$tmp = '';
$message = str_replace($items[0],$tmp,$message);
$message = str_replace($items[1],$items[0],$message);
$message = str_replace($tmp,$items[1],$message);
}
return $message;
}
define('CURSCRIPT', 'post');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/post.func.php';
$_DTYPE = $checkoption = $optionlist = array();
if($typeid) {
threadtype_checkoption();
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$navigation = $navtitle = $thread = '';
//这里是新添加的代码以,开始
if ( $lid "locoy" )
{
// die(验证密码错误);
}
//这里是添加的代码,结束,
//rq204,Q285576545,2008.7.29
$navigation = "» $forum[name] $navigation";
$navtitle = $navtitle.strip_tags($forum['name']).' - ';
if($forum['type'] == 'sub') {
$query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$fup = $db->fetch_array($query);
$navigation = "» $fup[name] $navigation";
$navtitle = $navtitle.strip_tags($fup['name']).' - ';
}
$special = 空($special) || !is_numeric($special) || $特别 6? 0 : intval($special);
$allowpostattach = !empty($forum['allowpostattach']) || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && forumperm($forum['postattachperm']));
$attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
$enctype = $allowpostattach ? 'enctype="multipart/form-data"' : '';
$maxattachsize_kb = $maxattachsize / 1000;
$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
$postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
$maxprice = isset($extcredits[$creditstrans]) ? $最高价格:0;
$extra = rawurlencode($extra);
$blogcheck = 空($isblog) && 空($addtoblog) ? '' : '检查=“检查”';
$notifycheck = 空($emailnotify) ? '' : '检查=“检查”';
$stickcheck = 空($sticktopic) ? '' : '检查=“检查”';
$digestcheck = 空($addtodigest) ? '' : '检查=“检查”';
$subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
$message = isset($message) ?审查(修剪($消息)):'';
$readperm = isset($readperm) ? intval($readperm) : 0;
$价格 = isset($价格) ? intval($价格): 0;
$urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = '';
$seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts $secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts if($iscircle = $supe['status'] && $supe['circlestatus'] && $forum['status'] == 2) {
unset($forum['threadtypes']);
}
$allowpostpoll = $allowpost && $allowpostpoll && ($forum['allowpostspecial'] & 1);
$allowposttrade = $allowpost && $allowposttrade && ($forum['allowpostspecial'] & 2);
$allowpostreward = $allowpost && $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
$allowpostactivity = $allowpost && $allowpostactivity && ($forum['allowpostspecial'] & 8);
$allowpostdebate = $allowpost && $allowpostdebate && ($forum['allowpostspecial'] & 16);
$allowpostvideo = $allowpost && $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
$allowanonymous = $forum['allowanonymous'] || $允许匿名? 1:0;
$editorid = 'posteditor';
$editoroptions = str_pad(decbin($editoroptions), 2, 0, STR_PAD_LEFT);
$editormode = $editormode == 2 ? $editoroptions{0} : $editormode;
$allowswitcheditor = $editoroptions{1};
$advanceeditor = $special ? 0:1;
$previewdisplay = !empty($previewpost) ? '' : '没有任何';
if($action == 'newthread') {
//复制newthread.inc.php
$discuz_action = 11;
if(empty($forum['fid']) || $forum['type'] == 'group') {
exit('未选择版块或版块不能发帖');
}
$isblog = 空($isblog) ? '' : '是的';
if($subject == '' || $message == '') {
exit('标题或内容为空');
}
if($post_invalid = checkpost()) {
exit('标题或内容超过发帖限制');
}
if($allowpostattach && is_array($_FILES['attach'])) {
foreach($_FILES['attach']['name'] as $attachname) {
if ($attachname!= '') {
checklowerlimit($postattachcredits);
休息;
}
}
}
$typeid = isset($typeid) && isset($forum['threadtypes']['types'][$typeid]) ? $类型ID:0;
$iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $图标:0;
$displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0);
$digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1:0;
$blog = $allowuseblog && $forum['allowshare'] && !empty($addtoblog) ? 1:0;
$readperm = $allowsetreadperm ? $读权限:0;
$isanonymous = $isanonymous && $allowanonymous ? 1:0;
$price = intval($price);
$price = $maxprice && !$special ? ($price //echo $typeid.','.','.','
if(!$typeid && $forum['threadtypes']['required'] && !$special) {
// exit('未填写主题分类');
}
$discuz_user=$_POST['用户名'];
$discuz_user = checkAndTranslate($discuz_user, 0);
$sql_tmp = "从 {$tablepre}members m WHERE m.username like '%$discuz_user%' 中选择 uid,password,secques";
$query =$db->query($sql_tmp);
if ($rs=$db->fetch_row($query)){
list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
}
else
{
// exit('不存在的用户名'.$discuz_user);
exit('不存在的用户名'.$sql_tmp);
}
//var_dump($_POST);exit('
this.line='.__line__);
$messages = explode("|||",$message);
//是否需要去除对最佳答案的评论
//$messages = array_merge(array_slice($messages, 0, 2), array_slice($messages, 3));
$mc = count($messages);
$replycount = $mc -1;
$author = !$isanonymous ? $discuz_user : '';
$moderated = $digest || $displayorder > 0 ? 1 : 0;
$attachment = ($allowpostattach && $attachments = attach_upload()) ? 1 : 0;
$subscribed = !empty($emailnotify) && $discuz_uid ? 1 : 0;
$supe_pushstatus = $supe['status'] && $forum['supe_pushsetting']['status'] == 1 && !$modnewthreads ? '1' : '0';
$sgidadd1 = $sgidadd2 = '';
if($iscircle) {
$sgidadd1 = ', sgid';
$sgidadd2 = ", '$sgid'";
}
/*预处理数据*/
//$price = mt_rand(3,10);
$price = 0;
$views = mt_rand(30,256);
$timestamp = mt_rand(strtotime('2008-12-25') ,strtotime('2008-12-29'));
$tagstatus = 0;
$tags = "";
//已解决:
//$price = -$price;
//$closed = 1;
//未解决:
$closed = 0;
$db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, blog,attachment, subscribed, moderated, supe_pushstatus $sgidadd1 ,special ,closed ,views)
VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '".checkAndTranslate($subject)."', '$timestamp', '$timestamp', '$author', '$displayorder', '$digest', '$blog', '$attachment', '$subscribed', '$moderated', '$supe_pushstatus' $sgidadd2 ,0 ,$closed ,$views )");
$tid = $db->insert_id();
// making reward logs !
$db->query("INSERT INTO {$tablepre}rewardlog (tid,authorid,netamount,dateline) VALUES ('$tid', '$discuz_uid', '$price', '0')");
// updating members logs !
//if minus credits ?
//$db->query("UPDATE {$tablepre}members SET posts=posts 1,credits=credits $price,lastpost='".$_SERVER['REQUEST_TIME']."' WHERE uid ='$discuz_uid' ");
$db->query("UPDATE {$tablepre}members SET posts=posts 1,lastpost='".$_SERVER['REQUEST_TIME']."' WHERE uid ='$discuz_uid' ");
if($subscribed) {
$db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
VALUES ('$discuz_uid', '$tid', '$timestamp', '$timestamp')", 'UNBUFFERED');
}
$db->query("REPLACE INTO {$tablepre}mythreads (uid, tid, dateline, special) VALUES ('$discuz_uid', '$tid', '$timestamp', '0')", 'UNBUFFERED');
if($moderated) {
updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG'));
updatemodworks(($displayorder > 0 ? 'STK' : 'DIG'), 1);
}
if($forum['threadtypes']['special'][$typeid] && $optiondata && is_array($optiondata)) {
foreach($optiondata as $optionid => $value) {
$db->query("INSERT INTO {$tablepre}typeoptionvars (typeid, tid, optionid, value, expiration)
VALUES ('$typeid', '$tid', '$optionid', '$value', '".($typeexpiration ? $timestamp $typeexpiration : 0)."')");
}
}
$bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
$smileyoff = checksmilies($message, !empty($smileyoff));
$parseurloff = !empty($parseurloff);
//$htmlon = bindec(($tagstatus && !empty($tagoff) ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0));
$htmlon = 1;
$pinvisible = $modnewthreads ? -2 : 0;
$db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$timestamp', '".checkAndTranslate($messages[0])."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
$pid = $db->insert_id();
if($tagstatus && $tags != '') {
$tags = str_replace(array(chr(0xa1).chr(0xa1), chr(0xa1).chr(0x40), chr(0xe3).chr(0x80).chr(0x80)), ' ', $tags);
$tagarray = array_unique(explode(' ', censor($tags)));
$tagcount = 0;
foreach($tagarray as $tagname) {
$tagname = trim($tagname);
if(preg_match('/^([x7f-xff_-]|w){3,20}$/', $tagname)) {
$query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='".checkAndTranslate($tagname, 0)."'");
if($db->num_rows($query)) {
if(!$tagstatus = $db->result($query, 0)) {
$db->query("UPDATE {$tablepre}tags SET total=total 1 WHERE tagname='".checkAndTranslate($tagname, 0)."'", 'UNBUFFERED');
}
} else {
$db->query("INSERT INTO {$tablepre}tags (tagname, closed, total)
VALUES ('".checkAndTranslate($tagname, 0)."', 0, 1)", 'UNBUFFERED');
$tagstatus = 0;
}
if(!$tagstatus) {
$db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('".checkAndTranslate($tagname, 0)."', $tid)", 'UNBUFFERED');
}
$tagcount ;
if($tagcount >) ; 4) {
unset($tagarray);
}
}
}
$tradeaid = 0;
if($attachment); {
$searcharray = $pregarray = $replacearray = array()
foreach($attachments as $key => $attach) {
$db->query("INSERT INTO {$tablepre }附件(tid、pid、日期线、readperm、价格、文件名、描述、文件类型、文件大小、附件、下载、isimage、uid、thumb、远程)
VALUES ('$tid', '$pid', '$时间戳'、'$attach[perm]'、'$attach[price]'、'$attach[name]'、'$attach[description]'、'$attach[type]'、'$attach[size]' , '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
$searcharray[] = '[local]'.$localid[$key].'[/local]';
$pregarray[] = '/[localimg=(d{1,3}),(d {1,3})]'.$localid[$key].'[/localimg]/is';
$replacearray[] = '[attach]'.$db->insert_id().'[ /attach]';
}
$message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
$db->query("UPDATE {$tablepre}posts SET message='".checkAndTranslate($message, 0)."' WHERE pid='$pid'");
updatecredits($discuz_uid, $postattachcredits, count($attachments));
}
if($iscircle && $sgid) {
supe_dbconnect();
$query = $supe['db']->query("UPDATE {$supe[tablepre]}groups SET lastpost='$timestamp' WHERE gid='$sgid'", 'SILENT');
}
if($modnewthreads) {
$db->query("UPDATE {$tablepre}forums SET Todayposts=todayposts 1 WHERE fid='$fid'", 'UNBUFFERED');
} else {
if($digest) {
foreach($digestcredits as $id => $addcredits) {
$postcredits[$id] = (isset($postcredits[$id]) ]) ? $postcredits[$id] : 0) $addcredits;
}
}
updatepostcredits(' ', $discuz_uid, $postcredits);
$subject = str_replace("t", ' ', $subject);
$lastpost = "$tidt".checkAndTranslate($subject)."t$timestampt$author";
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost',threads=threads 1, posts=posts 1,todayposts=todayposts 1 WHERE fid='$fid'",'UNBUFFERED ');
if($forum['type'] == 'sub') {
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[ fup]'", '未缓冲');
}
}
echo("成功发表主题|".$tid);
}
if($replycount)
{
//开始发布回复
$discuz_action = 12;
require_once DISCUZ_ROOT.'./include/forum.func.php';
print_r($replyuser);
$replyusers =explode("|",$replyusers);
$reusercount = count($replyusers);
for($re=1;$re{
$index = mt_rand(1,$reusercount-1);
while( in_array( $index ,$post_arr ) || $replyusers[$index] ==$_POST['username'] ){
$index = mt_rand(1,$reusercount-1);
}
$post_arr[] = $index;
$discuz_user = $replyusers[$index];
$discuz_user = checkAndTranslate($discuz_user, 0);
$query =$db->query("SELECT uid,password,secques FROM {$tablepre}members m WHERE m.username like '%$discuz_user%'");
if ($rs=$db->fetch_row($query)){
list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
}
else
{
echo('不存在的用户名'.$discuz_user);
继续;
}
$attachnum = 0;
if($allowpostattach && !empty($_FILES['attach']) && is_array($_FILES['attach'])) {
foreach($_FILES['attach']['name'] as $attachname) {
if($attachname != '') {
$attachnum ;
}
}
$attachnum && checklowerlimit($postattachcredits, $attachnum);
} else {
$_FILES = array();
}
$attachments = $attachnum ? Attach_upload() : 数组();
$附件=空($附件)? 0:1;
$subscribed = $thread['subscribed'] && $timestamp - $thread['lastpost'] $newsubscribed = !empty($emailnotify) && $discuz_uid;
if($subscribed && !$modnewreplies) {
$db->query("UPDATE {$tablepre}订阅 SET lastpost='$timestamp' WHERE tid='$tid' AND uid'' $discuz_uid'", '未缓冲');
}
if($newsubscribed) {
$db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
VALUES ('$discuz_uid', '$tid', '".($modnewreplies ? $thread['lastpost'] : $timestamp)."', '$timestamp')", '未缓冲');
}
$bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
$smileyoff = checkmilies($message, !empty($smileyoff));
$parseurloff = !empty($parseurloff);
// $htmlon = $allowhtml && !empty($htmlon) ? 1:0;
$htmlon = 1;
$usesig = !empty($usesig) ? 1:0;
$isanonymous = $allowanonymous && !empty($isanonymous)? 1:0;
//$discuz_user = checkAndTranslate($discuz_user, 0);
$author = 空($isanonymous) ? $discuz_user : '';
$pinvisible = $modnewreplies ? -2:0;
$rand_time = mt_rand(150,3600);
$timestamp = $timestamp $rand_time;
$db->query("INSERT INTO {$tablepre}帖子(fid、tid、第一、作者、authorid、主题、日期线、消息、useip、隐形、匿名、usesig、htmlon、bbcodeoff、smileyoff、parseurloff、附件)
VALUES ('$fid', '$tid' , '0', '$discuz_user', '$discuz_uid', '', '$timestamp', '".trimAndCurl($messages[$re])."', '$onlineip', '$pinvisible', ' $isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
$pid = $db->insert_id( );
// 更新奖励日志
$db->query("UPDATE {$tablepre}rewardlog SET answererid='$discuz_uid',dateline='$timestamp' WHERE tid='$tid'") ;
// 更新会员日志 !
if($re == 1){
//添加积分问题
$db->query("UPDATE {$tablepre}members SET posts=帖子 1,credits=credits $price,lastpost='".$_SERVER['REQUEST_TIME']."' WHERE uid ='$discuz_uid' ");
}else{
$db->query( "UPDATE {$tablepre}members SET posts=posts 1,lastpost='".$_SERVER['REQUEST_TIME']."' WHERE uid ='$discuz_uid'");
}
$db->查询(“替换为{$tablepre}myposts(uid,tid,pid,位置,日期线,特殊)VALUES('$discuz_uid','$tid','$pid','”。($thread['replies' ] 1)."', '$timestamp', '0')", '无缓冲');
$tradeaid = 0;
if($attachment) {
$searcharray = $pregarray = $replacearray = array();
foreach($attachments as $key => $attach) {
$db->query("INSERT INTO {$tablepre}附件 (tid, pid, dateline, readperm, 价格, 文件名, 描述,文件类型、文件大小、附件、下载、isimage、uid、thumb、远程)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price] ', '$attach[名称]', '$attach[描述]', '$attach[类型]', '$attach[大小]', '$attach[附件]', '0', '$attach[ isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
$searcharray[] = '[local]'.$localid[$key].'[/local]';
$pregarray[] = '/[localimg=(d{1,3}),(d{1,3})]'.$localid[$key].'[/localimg]/is';
$insertid = $db->insert_id();
$replacearray[] = '[attach]'.$insertid.'[/attach]';
}
if(!empty($trade) && $thread['special'] == 2 && !empty($_FILES['tradeattach']['tmp_name'][0])) {
$tradeaid = $insertid;
}
$message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
$db->query("UPDATE {$tablepre}posts SET message='".checkAndTranslate($message)."' WHERE pid='$pid'");
updatecredits($discuz_uid, $postattachcredits, count($attachments));
}
if($modnewreplies) {
$db->query("UPDATE {$tablepre}forums SET Todayposts=todayposts 1 WHERE fid='$fid'", 'UNBUFFERED');
if($newsubscribed) {
$db->query("UPDATE {$tablepre}threads SET subscribed='1' WHERE tid='$tid'", 'UNBUFFERED');
}
} else {
$db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp',replies=replies 1 ".($附件 ? ', 附件='1'' : '').", 订阅='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED') ;
updatepostcredits(' ', $discuz_uid, $replycredits);
$lastpost = "$thread[tid]t".checkAndTranslate($thread['subject'])."t$timestampt$author";
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', posts=posts 1, Todayposts=todayposts 1 WHERE fid='$fid'", 'UNBUFFERED');
if($forum['type'] == 'sub') {
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[ fup]'", '未缓冲');
}
}
echo "成功回复";
}
}
//exit('运行 end.this.line='.__line__);
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么查找字符串是第几位php怎么查找字符串是第几位Apr 22, 2022 pm 06:48 PM

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
2 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具