導航:首頁 > 編程語言 > php讓水印文字居中

php讓水印文字居中

發布時間:2022-04-25 09:21:51

php居中代碼是什麼

內容居中是頁面布局進行設置的,和php是沒有關系的,想要實現內容居中,可以通過text-align:center等css樣式,具體的方法如下:

1.直接對body設置CSS樣式:text-align:center;

Ⅱ php寫出的文字怎麼居中

呃,我想你誤會了php的功能了,文字居中是樣式問題,屬於html/css
<body style="text-align:center">
<p><?php echo "asdfasdf"; ?><p>

</body>

Ⅲ word水印不居中怎麼辦

雙擊頁眉或頁腳的位置進入頁眉頁腳編輯狀態,點擊選中水印後右鍵,選擇設置圖片格式,在版式窗口可以看到居中選項,這是自定義的水印,自帶的「絕密」之類的的水印方法一樣,但是右鍵出來的菜單選擇設置藝術字格式選項。

Ⅳ 急!請幫看一下PHP源代碼,要怎麼弄才能實現輸出的文字自動居中對齊

$len = mb_strlen($namea,"UTF-8");
$left_x = (640-$len*30)/2;
imagettftext($im, 30, 0, $left_x, 370, $black, $font, $namea);

Ⅳ php代碼在網頁上顯示怎麼居中

用center標簽即可。
<center>This text will be center-aligned.</center>

Ⅵ Php里的文字怎麼居中的

這是css做的事,不是php做的事;
css水平居中 text-align:center
css垂直居中 height:30px; line-height:30px;

Ⅶ php代碼在網頁上怎麼設置顯示居中

你是不是搞錯了,
php是伺服器腳本,顯示居中這是瀏覽器腳本的事
你可以在html頁面直接設置,或者css、js也行

Ⅷ php圖片水印代碼問題拜託了各位 謝謝

不顯示的話就是你沒輸出來,請參考以下代碼重新檢查一遍: ------------------------------華麗分割線------------------------------------- <? /* * 功能:PHP圖片水印 (水印支持圖片或文字) * 參數: * $groundImage 背景圖片,即需要加水印的圖片,暫只支持GIF,JPG,PNG格式; * $waterPos 水印位置,有10種狀態,0為隨機位置; * 1為頂端居左,2為頂端居中,3為頂端居右; * 4為中部居左,5為中部居中,6為中部居右; * 7為底端居左,8為底端居中,9為底端居右; * $waterImage 圖片水印,即作為水印的圖片,暫只支持GIF,JPG,PNG格式; * $waterText 文字水印,即把文字作為為水印,支持ASCII碼,不支持中文; * $fontSize 文字大小,值為1、2、3、4或5,默認為5; * $textColor 文字顏色,值為十六進制顏色值,默認為#CCCCCC(白灰色); * $fontfile ttf字體文件,即用來設置文字水印的字體。使用windows的用戶在系統盤的目錄中 * 搜索*.ttf可以得到系統中安裝的字體文件,將所要的文件拷到網站合適的目錄中, * 默認是當前目錄下arial.ttf。 * $xOffset 水平偏移量,即在默認水印坐標值基礎上加上這個值,默認為0,如果你想留給水印留 * 出水平方向上的邊距,可以設置這個值,如:2 則表示在默認的基礎上向右移2個單位,-2 表示向左移兩單位 * $yOffset 垂直偏移量,即在默認水印坐標值基礎上加上這個值,默認為0,如果你想留給水印留 * 出垂直方向上的邊距,可以設置這個值,如:2 則表示在默認的基礎上向下移2個單位,-2 表示向上移兩單位 * 返回值: * 0 水印成功 * 1 水印圖片格式目前不支持 * 2 要水印的背景圖片不存在 * 3 需要加水印的圖片的長度或寬度比水印圖片或文字區域還小,無法生成水印 * 4 字體文件不存在 * 5 水印文字顏色格式不正確 * 6 水印背景圖片格式目前不支持 * 修改記錄: * * 注意:Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG * $waterImage 和 $waterText 最好不要同時使用,選其中之一即可,優先使用 $waterImage。 * 當$waterImage有效時,參數$waterString、$stringFont、$stringColor均不生效。 * 加水印後的圖片的文件名和 $groundImage 一樣。 * 作者:高西林 * 日期:2007-4-28 * 說明:本程序根據longware的程序改寫而成。 */ function imageWaterMark($groundImage,$waterPos=0,$waterImage="",$waterText="",$fontSize=12,$textColor="#CCCCCC", $fontfile='./arial.ttf',$xOffset=0,$yOffset=0) { $isWaterImage = FALSE; //讀取水印文件 if(!empty($waterImage) && file_exists($waterImage)) { $isWaterImage = TRUE; $water_info = getimagesize($waterImage); $water_w = $water_info[0];//取得水印圖片的寬 $water_h = $water_info[1];//取得水印圖片的高 switch($water_info[2]) { //取得水印圖片的格式 case 1:$water_im = imagecreatefromgif($waterImage);break; case 2:$water_im = imagecreatefromjpeg($waterImage);break; case 3:$water_im = imagecreatefrompng($waterImage);break; default:return 1; } } //讀取背景圖片 if(!empty($groundImage) && file_exists($groundImage)) { $ground_info = getimagesize($groundImage); $ground_w = $ground_info[0];//取得背景圖片的寬 $ground_h = $ground_info[1];//取得背景圖片的高 switch($ground_info[2]) { //取得背景圖片的格式 case 1:$ground_im = imagecreatefromgif($groundImage);break; case 2:$ground_im = imagecreatefromjpeg($groundImage);break; case 3:$ground_im = imagecreatefrompng($groundImage);break; default:return 1; } } else { return 2; } //水印位置 if($isWaterImage) { //圖片水印 $w = $water_w; $h = $water_h; $label = "圖片的"; } else { //文字水印 if(!file_exists($fontfile))return 4; $temp = imagettfbbox($fontSize,0,$fontfile,$waterText);//取得使用 TrueType 字體的文本的范圍 $w = $temp[2] - $temp[6]; $h = $temp[3] - $temp[7]; unset($temp); } if( ($ground_w < $w) || ($ground_h < $h) ) { return 3; } switch($waterPos) { case 0://隨機 $posX = rand(0,($ground_w - $w)); $posY = rand(0,($ground_h - $h)); break; case 1://1為頂端居左 $posX = 0; $posY = 0; break; case 2://2為頂端居中 $posX = ($ground_w - $w) / 2; $posY = 0; break; case 3://3為頂端居右 $posX = $ground_w - $w; $posY = 0; break; case 4://4為中部居左 $posX = 0; $posY = ($ground_h - $h) / 2; break; case 5://5為中部居中 $posX = ($ground_w - $w) / 2; $posY = ($ground_h - $h) / 2; break; case 6://6為中部居右 $posX = $ground_w - $w; $posY = ($ground_h - $h) / 2; break; case 7://7為底端居左 $posX = 0; $posY = $ground_h - $h; break; case 8://8為底端居中 $posX = ($ground_w - $w) / 2; $posY = $ground_h - $h; break; case 9://9為底端居右 $posX = $ground_w - $w; $posY = $ground_h - $h; break; default://隨機 $posX = rand(0,($ground_w - $w)); $posY = rand(0,($ground_h - $h)); break; } //設定圖像的混色模式 imagealphablending($ground_im, true); if($isWaterImage) { //圖片水印 image($ground_im, $water_im, $posX + $xOffset, $posY + $yOffset, 0, 0, $water_w,$water_h);//拷貝水印到目標文件 } else {//文字水印 if( !empty($textColor) && (strlen($textColor)==7) ) { $R = hexdec(substr($textColor,1,2)); $G = hexdec(substr($textColor,3,2)); $B = hexdec(substr($textColor,5)); } else { return 5; } imagettftext ( $ground_im, $fontSize, 0, $posX + $xOffset, $posY + $h + $yOffset, imagecolorallocate($ground_im, $R, $G, $B), $fontfile, $waterText); } //生成水印後的圖片 @unlink($groundImage); switch($ground_info[2]) {//取得背景圖片的格式 case 1:imagegif($ground_im,$groundImage);break; case 2:imagejpeg($ground_im,$groundImage);break; case 3:imagepng($ground_im,$groundImage);break; default: return 6; } //釋放內存 if(isset($water_info)) unset($water_info); if(isset($water_im)) imagedestroy($water_im); unset($ground_info); imagedestroy($ground_im); // return 0; } ?> <?php ////////////////////// if(isset($_POST['submit'])) { if(isset($_FILES) && !empty($_FILES['userfile']) && $_FILES['userfile']['size']>0) { $uploadfile = "./".time()."_".$_FILES['userfile']['name']; if (($_FILES['userfile']['tmp_name'], $uploadfile)) { if($_POST['watertype'] == 0) { $msg = "returnvalue=".imageWaterMark($uploadfile,$_POST['waterpos'],"",$_POST['watercontent'],$_POST['fontsize'],$_POST['fontcolor'],$_POST['fontfile'],$_POST['xoffset'],$_POST['yoffset']); } else { $msg = "returnvalue=".imageWaterMark($uploadfile,$_POST['waterpos'],$_POST['watercontent']); } echo "<img src=\"".$uploadfile."\" border=\"0\">"; } else { $msg = "Fail!"; } } } ?> <html> <head> <meta http-equiv=content-type content="text/html; charset=utf-8"> <title>水印函數測試</title> </head> <body> <form enctype="multipart/form-data" method="POST"> <table> <tr> <td><input name="watertype" type="radio" value=0 checked>文字水印<input type="radio" name="watertype" value=1>水印圖片</td> </tr> <tr> <td><input name="watercontent" value="blog.csdn.net/alin0725">水印文字內容或水印圖片文件名</td> </tr> <tr> <td><input name="fontcolor" value="#CCCCCC">文字水印顏色</td> </tr> <tr> <td><input name="fontsize" value="10">文字字體大小</td> </tr> <tr> <td><input name="fontfile" value="./arial.ttf">文字字體文件ttf格式</td> </tr> <tr> <td>水印位置<input name="waterpos" value=0> 0為隨機,其他位置值如下: <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> </table> </td> </tr> <tr> <td>x方向上的偏移量<input name="xoffset" value=0>y方向上的偏移量<input name="yoffset" value=0> </td> <tr> <tr> <td>背景圖片: <input name="userfile" type="file"> </td> </tr> <tr> <td><input type="submit" name="submit" value="提交"></td> </tr> <tr> <td>消息:<?php echo $msg; ?></td> </tr> </table> </form> </body> </html>

Ⅸ PHP怎麼把全部頁面居中

頁面居中需要用css控制html

用到的css居中的style有text-align:center; 和 margin:0pxauto

舉例為:

<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>無標題</title>
</head>
<bodystyle="text-align:center;">
<divstyle="margin:0pxauto">

頁面

</div>
</body>
</html>

Ⅹ PHP給圖片添加文字水印

請確認C:\WINDOWS\Fonts\simkai.ttf';是否支持中文
或不要轉換
$str = iconv('GB2312','UTF-8',$str);
直接
$str=$str;

閱讀全文

與php讓水印文字居中相關的資料

熱點內容
python列表求交集 瀏覽:872
解壓包如何轉音頻 瀏覽:447
機明自動編程軟體源碼 瀏覽:325
php埠號設置 瀏覽:540
phperegreplace 瀏覽:320
androidgridview翻頁 瀏覽:537
ssh協議編程 瀏覽:634
如何開我的世界電腦伺服器地址 瀏覽:861
玄關pdf 瀏覽:609
程序員學習論壇 瀏覽:940
程序員的毒雞湯怎麼做 瀏覽:548
安卓怎麼降級軟體到手機 瀏覽:281
雲與伺服器入門書籍推薦產品 瀏覽:636
delphi編程助手 瀏覽:762
電腦遇到伺服器問題怎麼辦 瀏覽:515
加工中心編程結束方法 瀏覽:296
了解什麼是web伺服器 瀏覽:140
面向對象的編程的基本特徵 瀏覽:718
php定時執行任務linux 瀏覽:787
php數組中刪除元素 瀏覽:725