欧美日韩不卡一区二区三区,www.蜜臀.com,高清国产一区二区三区四区五区,欧美日韩三级视频,欧美性综合,精品国产91久久久久久,99a精品视频在线观看

php語言

最PHP實(shí)例代碼21個(gè)

時(shí)間:2025-02-21 07:09:06 php語言 我要投稿
  • 相關(guān)推薦

最實(shí)用的PHP實(shí)例代碼21個(gè)

  PHP 是一種 HTML 內(nèi)嵌式的語言,是一種在服務(wù)器端執(zhí)行的嵌入HTML文檔的腳本語言,語言的風(fēng)格有類似于C語言,被廣泛的運(yùn)用。以下是百分網(wǎng)小編搜索整理的關(guān)于最實(shí)用的PHP實(shí)例代碼21個(gè),供參考借鑒,希望對(duì)大家有所幫助!想了解更多相關(guān)信息請(qǐng)持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!

  1. PHP可閱讀隨機(jī)字符串

  此代碼將創(chuàng)建一個(gè)可閱讀的字符串,使其更接近詞典中的單詞,實(shí)用且具有密碼驗(yàn)證功能。

  /**************

  *@length - length of random string (must be a multiple of 2)

  **************/

  function readable_random_string($length = 6){

  $conso=array("b","c","d","f","g","h","j","k","l",

  "m","n","p","r","s","t","v","w","x","y","z");

  $vocal=array("a","e","i","o","u");

  $password="";

  srand ((double)microtime()*1000000);

  $max = $length/2;

  for($i=1; $i<=$max; $i++)

  {

  $password.=$conso[rand(0,19)];

  $password.=$vocal[rand(0,4)];

  }

  return $password;

  }

  2. PHP生成一個(gè)隨機(jī)字符串

  如果不需要可閱讀的字符串,使用此函數(shù)替代,即可創(chuàng)建一個(gè)隨機(jī)字符串,作為用戶的隨機(jī)密碼等。

  /*************

  *@l - length of random string

  */

  function generate_rand($l){

  $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

  srand((double)microtime()*1000000);

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

  $rand.= $c[rand()%strlen($c)];

  }

  return $rand;

  }

  3. PHP編碼電子郵件地址

  使用此代碼,可以將任何電子郵件地址編碼為 html 字符實(shí)體,以防止被垃圾郵件程序收集。

  function encode_email($email=’info@domain.com’, $linkText=’Contact Us’, $attrs =’class="emailencoder"’ )

  {

  // remplazar aroba y puntos

  $email = str_replace(’@’, ’@’, $email);

  $email = str_replace(’.’, ’.’, $email);

  $email = str_split($email, 5);

  $linkText = str_replace(’@’, ’@’, $linkText);

  $linkText = str_replace(’.’, ’.’, $linkText);

  $linkText = str_split($linkText, 5);

  $part1 = ’’;

  $part4 = ’’;

  $encoded = ’

script type="text/javascript"’;

  $encoded .= "document.write(’$part1’);";

  $encoded .= "document.write(’$part2’);";

  foreach($email as $e)

  {

  $encoded .= "document.write(’$e’);";

  }

  $encoded .= "document.write(’$part3’);";

  foreach($linkText as $l)

  {

  $encoded .= "document.write(’$l’);";

  }

  $encoded .= "document.write(’$part4’);";

  $encoded .= ’/script

【最PHP實(shí)例代碼21個(gè)】相關(guān)文章:

PHP實(shí)用的代碼實(shí)例08-12

學(xué)習(xí)php分頁代碼實(shí)例10-11

實(shí)用的PHP實(shí)例代碼20個(gè)06-11

實(shí)用的PHP語言實(shí)例代碼06-13

PHP時(shí)間戳使用實(shí)例代碼10-16

php生成sitemap.xml的實(shí)例代碼06-02

PHP中檢測(cè)ajax請(qǐng)求的代碼實(shí)例10-25

PHP開發(fā)微信支付實(shí)例代碼09-01

PHP時(shí)間戳使用實(shí)例代碼「詳細(xì)版」09-13