当前位置:首页 » 编程语言 » php文字代码

php文字代码

发布时间: 2022-07-02 21:43:19

⑴ 求一段php文字生成图片的代码

把imageString()去掉,加上下面的代码试试,很多人用这做图片水印的-_-!
$font_file = "字体文件的路径";
$str = '我爱PHP!';
$str = mb_convert_encoding($str,"UTF-8","GBK");
imagettftext('图像','字体大小','角度',x,y,'颜色',$font_file,$str);

⑵ 文字转Unicode编码的php代码如何写

sybase_connect
连上数据库
语法: int sybase_connect(string [servername], string [username], string [password]);
返回值: 整数
函数种类: 数据库功能
本函数用来打开与 Sybase 数据库的连接。参数 servername 为欲连上的数据库服务器名称。参数 username 及 password 可省略,分别为连接使用的帐号及密码。使用本函数需注意早点关闭数据库,以减少系统的负担。连接成功则返回数据库的连接代号,失败返回 false 值。

⑶ PHP文字统计求代码(包括标点、英文字母、空格等)求大神帮助啊!!!!

$txtStr = "aksdfas ;ooawer ";
$cntArr = array();
$len = strlen($txtStr);
for($i=0; $i<$len; $i++)
{
$ch = substr($txtStr,$i,1);
is_null($cntArr[$ch]) ? $cntArr[$ch] = 0; : $cntArr[$ch]++;
}
printf($cntArr);

⑷ php居中代码是什么

内容居中是页面布局进行设置的,和php是没有关系的,想要实现内容居中,可以通过text-align:center等css样式,具体的方法如下:

1.直接对body设置CSS样式:text-align:center;

⑸ 求PHP常用代码大全

if ($da="") { echo "<SCRIPT language=javaScript>alert('问题答案不能为空');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } if ($qq!="") { if (!is_numeric($qq)) { echo "<SCRIPT language=JavaScript>alert('QQ号码必须是数字');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } } if ($youbian=="" or strlen($youbian)!=6) { echo "<SCRIPT language=JavaScript>alert('请正确输入邮编');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } if ($youbian!="") { if (!is_numeric($youbian)) { echo "<SCRIPT language=JavaScript>alert('邮编必须是数字');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } } if ($di="") { echo "<SCRIPT language=JavaScript>alert('住址不能为空');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } if ($mail=="") { echo "<SCRIPT language=JavaScript>alert('E-mail不能为空!');"; echo "this.location.href='vbscript:history.back()';</SCRIPT>"; } if ($textarea=="") { echo "<SCRIPT language=JavaScript>alert('个人说明不能为空!');"; echo "this.location.href='vbscript:history.back()';</SCRIPT>"; } if ($textarea=="" or strlen(textarea)>150) { echo "<SCRIPT language=JavaScript>alert('个人说明为150个字符');"; echo"this.location.href='vbscript:history.back()';</SCRIPT>"; } 24、对输出的内容进行判断,从而输出其它结果 <?php if ($rs["active"]==1) { echo "<font color='#ff0000'>激活</font>"; }else{ echo "禁用"; } ?> 25.字符截取函数 <?=substr("$rs[zixun_biaoti]",0,28 )?> 26.男女问题或单选带选择的 <input type="radio" name="hy_zhuangtai" value="男" <?php if ($rs["hy_zhungtai"]==="男") { echo "checked";}?>> 男 <input type="radio" name="hy_zhuangtai" value="女" <?php if ($rs["hy_zhuangtai"]==="女") { echo "checked";}?>> 女 27.单选不带单选框的 <?php if ($rs['hy_zhuangtai']=='锁定'){?> <a href="Userzt.php?action=yes&id=<?php echo $rs['hy_id'];?>">锁定</a> <?php } else{ ?><a href="Userzt.php?id=<?php echo $rs['hy_id'];?>&action=no">解锁</a> <?php }?> 它的save页是 <?php require_once('../../conn.php'); ?> <?php $hy_id=$_GET['id']; $action=$_GET['action']; if ($action=='yes'){ $sql="update hybiao set hy_zhuangtai='锁定' where hy_id='$id'"; $query=mysql_query($sql,$connec); echo("<script type='text/javascript'>location.href='UserManage.php';</script>"); } else{ $sql="update hybiao set hy_zhuangtai='正常' where hy_id='$id'"; $query=mysql_query($sql,$connec); echo("<script type='text/javascript'>location.href='UserManage.php';</script>"); } mysql_close(); ?> 28.如果文字过长,则将过长的部分变成省略号显示 <DIV STYLE="width: 120px; height: 50px; border: 0px solid blue;overflow: hidden; text-overflow:ellipsis"> <NOBR>就是比如有一行文字,很长,表格内一行显示不下.</NOBR> </DIV> 29. 禁止复制,鼠标拖动选取 <body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false> 30.大中小 文字的变化 <script type="text/javascript"> function doZoom(size) {document.getElementById('zoom').style.fontSize=size+'px';} </script> <span id="zoom">需要指定大小的文字</span> <a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a> 30. 添加到收藏夹和设为首页 <a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(' http://www.makewing.com/lanren/' );">设为首页</a> <a href="javascript:window.external.AddFavorite(' http://www.makewing.com/lanren/',' 懒人图库')">收藏本站</a> 31. 记录并显示网页的最后修改时间 <script language=JavaScript> document.write("最后更新时间: " + document.lastModified + "") </script> 32. 节日倒计时 <Script Language="JavaScript"> var timedate= new Date("October 1,2002"); var times= "国庆节"; var now = new Date(); var date = timedate.getTime() - now.getTime(); var time = Math.floor(date / (1000 * 60 * 60 * 24)); if (time >= 0) document.write( "现在离"+times+"还有: "+time +"天") </Script> 33. 打开窗口即最大化 <script language="JavaScript"> <!-- Begin self.moveTo(0,0) self.resizeTo(screen.availWidth,screen.availHeight) // End --> </script> 34. 加入背景音乐 <bgsound src="mid/windblue[1].mid" loop="-1"> 只适用于IE <embed src="music.mid" autostart="true" loop="true" hidden="true"> 对Netscape ,IE 都适用 35. 滚动 <marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollAmount=2> 滚动信息 </marquee> 36. 防止点击空链接时,页面往往重置到页首端 代码“javascript:void(null)”代替原来的“#”标记 37. 不能点右键,不用CTRL+A,不能复制作! <body oncontextmenu="window.event.returnValue=false" onkeypress="window.event.returnValue=false" onkeydown="window.event.returnValue=false" onkeyup="window.event.returnValue=false" ondragstart="window.event.returnValue=false" onselectstart="event.returnValue=false"> </body> 37. 随机变换背景图象(一个可以刷新心情的特效) <Script Language="JavaScript"> image = new Array(4); //定义image为图片数量的数组 image [0] = 'tu0.gif' //背景图象的路径 image [1] = 'tu1.gif' image [2] = 'tu2.gif' image [3] = 'tu3.gif' image [4] = 'tu4.gif' number = Math.floor(Math.random() * image.length); document.write("<BODY BACKGROUND="+image[number]+">"); </Script> 38. 划过链接 手型鼠标 style="cursor:hand" 39. 如何关闭层 <div id="Layer1"></div> <a href="#" onClick="Layer1.style.display='none'">关闭层</a> 40. <a href=javascript:close()>[关闭窗口]</a> 41. 凹陷文字背景为灰色 <div style="width:300px;padding:20px;overflow:hidden;word-wrap:break-word;word-break:break:all; font-size:12px; line-height:18px; background-color:#eeeeee;"> <font disabled> 怎么样,我凹下去了吧?<br> 你不想试试吗?<br> <a href=" www.lenvo.cn http://www.lenvo.cn/">www.lenvo.cn </div> 42. 给表格做链接 <table width="100%" onclick="window.open(' http://www.makewing.com/', '_blank')" style="CURSOR:hand"> <tr> <td height="100" bgcolor="f4f4f4"> </td> </tr> </table> 43. 后退&关闭窗口 后退:javascript:history.back(1) 关闭:javascript:window.close(); 44. 如果文字过长,则将过长的部分变成省略号显示 <DIV STYLE="width: 120px; height: 50px; border: 0px solid blue;overflow: hidden; text-overflow:ellipsis"> <NOBR>就是比如有一行文字,很长,表格内一行显示不下.</NOBR> </DIV> 45. 禁止复制,鼠标拖动选取 <body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>

⑹ 求高手写一段php代码,提取文本随机文字。高分赏!

mb_internal_encoding("UTF-8");

$str="们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在岭骗休借了不和有大这主中人上为来分生对于学下级地个用同行面说种过命度革而多子后自社加小机也经力线本霜";

//存放随机文字

$chars="";

//字符总数

$strlen=mb_strlen($str);

$rand_max=$strlen-1;

//2-10个字符数

$char_count=mt_rand(2,10);


//方式一:根据要取的字符个数,每次生成一个随机字符位置,获取字符。

//随即获取字符,共$char_count个字符

for($i=0;$i<$char_count;$i++){

//随机位置

$char_pos=mt_rand(0,$rand_max);

$chars.=mb_substr($str,$char_pos,1);

}

echo$chars;


//方式二:随机生成一个字符位置,作为起始位置,然后截取$char_count个

$chars="";

$char_pos=mt_rand(0,$rand_max);

$chars.=mb_substr($str,$char_pos,$char_count);

echo"<br/>$chars";


【显示】共执行了3次

⑺ 代码怎样写吖 PHP代码

<?php
$current = date("Y-m-d",time());//获取当前年月日并以Y-m-d的格式显示

$date_splite = explode("-",$current);//将获取到的字符串以 “-”符号分割成3个数组
$year = $date_splite[0];
$month = $date_splite[1];
$day = $date_splite[2];

$year_message = "";
if($year这里处理闰年的条件。。。){
$year_message = '今年是闰年';
}else{
$year_message = '今年不是闰年';

}

$season = ceil($month/3); //月份的值从1-12月。除3以后用ceil函数,进一取整,例如ceil(0.3)=1

$seasion_message = "";
switch($seasion){
case 1:

$seasion_message = "现在是XX季";

break;

case 2:

..

}

//最后向屏幕输出信息
echo '今天是'.date("Y年m月d日").'<br />';
echo $year_message.'<br />';
echo $seasion_message.'<br />'
?>

⑻ php 写网站 只要求输出一段文字,求老师指点,代码该怎么写,

具体要求是什么?如果只是要求输出一段文字,那直接输出就得了

<?php
echo('要输出的文字。。。');

⑼ 用php代码怎么以背景图片加上文字生成新的图片,然后在标题处绝对调用该图片

<?php
ob_clean(); //清除输出缓存
header("Content-type:image/jpeg"); //设置输出类型
$img="images/test.jpg"; //背景图片名
if(isset($_GET["img"]))$img=$_GET["img"]; //也可以通过img参数传入
$im=imagecreatefromjpeg($img); //读入背景图片
$text="文字内容"; //要加上的文字内容
if(isset($_GET["text"]))$text=$_GET["text"]; //也可以通过text参数传入
$fontFile="xxx.ttf"; //字体文件名,必须要
$fontSize=36; //字体尺寸
$fontColor=ImageColorAllocate($im,0,0,0); //字体颜色,这里是黑色
$textAngle=0; //文字显示的角度,0表示水平显示
$textLeft=20; //文字显示的x坐标
$textTop=60; //文字显示的y坐标
imagefttext($im,$fontSize,$textAngle,$textLeft,$textTop,$fontColor,$fontFile,$text); //把文字覆盖到图片上
Imagejpeg($im); //输出图片
ImageDestroy($im); //销毁图片
?>
把以上文字保存为php文件,比如 img.php
然后在需要调用图片的地方用 <img src="img.php?img=背景图片文件路径&text=要加上的文字"/> 来调用
比如 <img src="img.php?img=images/back.jpg&text=你好"/>

⑽ PHP网页滚动文字代码问题

<style type="text/css">

#demo {
background: #FFF;
overflow:hidden;

width: 765px;
}
#demo img {

}
#indemo {
float: left;
width: 800%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}

</style>

<DIV id=demo class="telnav">

<TABLE cellSpacing=0 cellPadding=0 align=left border=0 cellspace="0">

<TBODY>

<TR>

<TD id=demo1 vAlign=top>
<table width="950" height="50" border="2" cellpadding="1" cellspacing="1">
<tr>
<td>从右到左的滚动文字</td>
</tr>
</table>

</TD>

</div>

<TD id=demo2 vAlign=top></TD></TR></TBODY>

</TABLE>

</DIV>
<SCRIPT>

var speed=15

demo2.innerHTML=demo1.innerHTML

function Marquee(){

if(demo2.offsetWidth-demo.scrollLeft<=0)

demo.scrollLeft-=demo1.offsetWidth

else{

demo.scrollLeft++

}

}

var MyMar=setInterval(Marquee,speed)

demo.onmouseover=function() {clearInterval(MyMar)}

demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}

</SCRIPT>

热点内容
奶块脚本菜地 发布:2025-02-04 07:46:35 浏览:238
条形码识别源码 发布:2025-02-04 07:45:55 浏览:456
mysql数据库数据同步 发布:2025-02-04 07:41:07 浏览:760
安卓手机下载哪个北斗地图 发布:2025-02-04 07:35:26 浏览:854
查询服务器ip地址代码 发布:2025-02-04 07:08:28 浏览:675
python全双工 发布:2025-02-04 06:57:46 浏览:196
c语言动态内存 发布:2025-02-04 06:57:06 浏览:78
sql倒序查询 发布:2025-02-04 06:49:18 浏览:196
r7000p2021买哪个配置 发布:2025-02-04 06:40:17 浏览:968
如何消除微信小程序缓存 发布:2025-02-04 06:34:24 浏览:636