php代码兑现aes加密

Jun 13, 2016 am 10:58 AM
function

php代码实现aes加密
发现php4的加密模块在php5的不被支持了,硬要加上这个模块会导致启动时候出现警告对话框。
于是花了一天时间将as3的加密类翻译成了php的,该加密类是google的开源项目
http://code.google.com/p/as3crypto/


<?phprequire_once ("PKCS5.php");require_once("AESKey.php");require_once("ECBMode.php");require_once("Hex.php");class Aes{	private $_pad;//填充方式	private $_mode;//加密类	/**	 * 构造函数	 * @param	base64keyString   密钥base64编码字符串	 */	public function Aes($base64keyString) 	{		$this->_pad = new PKCS5(); //为了与java保持一致,所以采用PKCS5填充		$key = Hex::string2ByteArray(base64_decode($base64keyString));		$this->_mode = new ECBMode(new AESKey($key), $this->_pad);		$this->_pad->setBlockSize($this->_mode->getBlockSize());	}			/**	 * 将明文加密为密文base64编码字符串	 * @param	plainSrc		 明文	 * @return	密文base64编码	 */	public function encrypt($plainSrc)	{		$src = Hex::string2ByteArray($plainSrc);		$src = $this->_mode->encrypt($src);				return base64_encode(Hex::ByteArray2String($src));	}		/**	 * 将base64编码字符串(密文)解密成 明文	 * @param	base64Src  密文base64编码字符串	 * @return	明文	 */	public function decrypt($base64Src)	{		$src = base64_decode($base64Src);		$src = $this->_mode->decrypt(Hex::string2ByteArray($src));		return Hex::byteArray2String($src);	}		/**	 * 释放内存	 */	public function dispose()	{		$this->_mode->dispose();	}}//var_dump(Hex::string2ByteArray(base64_decode("MK2X82eL6jkKbzvlJU1ZMR6rcKO+SBhmbPOmFD/2Mxw=")));$_aes = new Aes("MK2X82eL6jkKbzvlJU1ZMR6rcKO+SBhmbPOmFD/2Mxw=");//echo "=================<br>";$ret = $_aes->encrypt("1234567890abcdef1234567890abcdefaaafdsfsdffasfasfasfasdf");echo $ret;var_dump($_aes->decrypt($ret));?>
Salin selepas log masuk


<?phprequire_once ("IPad.php");class PKCS5 implements IPad{	private $blockSize = 0;		public function PKCS5($blockSize=0) {		$this->blockSize = $blockSize;	}		public function pad($a)	{		$c = $this->blockSize-count($a)%$this->blockSize;		for ($i=0;$iblockSize;		if ($c!=0) throw new Exception("PKCS#5::unpad: ByteArray.length isn't a multiple of the blockSize");		$c = $a[$len-1];		array_splice($a,$len-$c,$c);		return $a;	}	public function setBlockSize($bs) 	{		$this->blockSize = $bs;	}}?>
Salin selepas log masuk




<?phprequire_once ("ISymmetricKey.php");require_once("AESKeyInclude.php");require_once("Hex.php");class AESKey implements ISymmetricKey{		private $_keyByte;	private $_keyLength;	private $_nNr;	private $_stateByte;	private $_tempByte;	public function AESKey($key/*:ByteArray*/) {		$this->_tempByte = array();		$this->_stateByte = array();		$this->_keyLength = count($key);		$this->_keyByte = $key;		$this->expandKey();	}		// produce Nb bytes for each round	private function expandKey() 	{		$tmp0=0;		$tmp1=0;		$tmp2=0;		$tmp3=0;		$tmp4=0;		$idx=0;		$Nk = $this->_keyLength/4;		//echo("count:".$Nk."<br>".count($this->_keyByte)."<br>");		$this->_nNr = $Nk+6;		$_keyByte = $this->_keyByte;		$_nNr = $this->_nNr;		$Nb = AESKeyInclude::$Nb;		$Sbox = AESKeyInclude::$_Sbox;		$Rcon = AESKeyInclude::$_Rcon;				for( $idx = $Nk; $idx  6 && $idx % $Nk == 4 ) {				$tmp0 = $Sbox[$tmp0];				$tmp1 = $Sbox[$tmp1];				$tmp2 = $Sbox[$tmp2];				$tmp3 = $Sbox[$tmp3];			}				$_keyByte[4*$idx+0] = $_keyByte[4*$idx - 4*$Nk + 0] ^ $tmp0;			$_keyByte[4*$idx+1] = $_keyByte[4*$idx - 4*$Nk + 1] ^ $tmp1;			$_keyByte[4*$idx+2] = $_keyByte[4*$idx - 4*$Nk + 2] ^ $tmp2;			$_keyByte[4*$idx+3] = $_keyByte[4*$idx - 4*$Nk + 3] ^ $tmp3;		}		$this->_keyByte = $_keyByte;	}	public function getBlockSize()	{		return 16;	}		// encrypt one 128 bit block	public function encrypt($block, $index=0)	{		$_stateByte = &$this->_stateByte;		$_keyByte = &$this->_keyByte;		$Nb = AESKeyInclude::$Nb;		$_nNr = $this->_nNr;				$_stateByte = array();		$_stateByte = array_merge($_stateByte,array_slice($block,$index,$Nb*4));		$this->addRoundKey($_keyByte, 0);		for ( $round = 1; $round mixSubColumns();			} else {				$this->shiftRows();			}			$this->addRoundKey($_keyByte, $round * $Nb * 4);		}		return $_stateByte;	}		public function decrypt($block, $index=0)	{		$_stateByte = &$this->_stateByte;		$_keyByte = &$this->_keyByte;		$Nb = AESKeyInclude::$Nb;		$_nNr = $this->_nNr;				$_stateByte = array();		$_stateByte = array_merge($_stateByte,array_slice($block,$index,$Nb*4));				$this->addRoundKey($_keyByte, $_nNr*$Nb*4);		$this->invShiftRows();		for( $round = $_nNr; $round--; )		{			$this->addRoundKey( $_keyByte, $round*$Nb*4);			if ($round) {				$this->invMixSubColumns();			}		}		return $_stateByte;	}		public function dispose() {			}	// exchanges columns in each of 4 rows	// row0 - unchanged, row1- shifted left 1, 	// row2 - shifted left 2 and row3 - shifted left 3	protected function shiftRows()	{		$tmp = 0;			$_stateByte = &$this->_stateByte;		$Sbox = AESKeyInclude::$_Sbox;				// just substitute row 0		$_stateByte[0] = $Sbox[$_stateByte[0]]; $_stateByte[4] = $Sbox[$_stateByte[4]];		$_stateByte[8] = $Sbox[$_stateByte[8]]; $_stateByte[12] = $Sbox[$_stateByte[12]];			// rotate row 1		$tmp = $Sbox[$_stateByte[1]]; $_stateByte[1] = $Sbox[$_stateByte[5]];		$_stateByte[5] = $Sbox[$_stateByte[9]]; $_stateByte[9] = $Sbox[$_stateByte[13]]; $_stateByte[13] = $tmp;			// rotate row 2		$tmp = $Sbox[$_stateByte[2]]; $_stateByte[2] = $Sbox[$_stateByte[10]]; $_stateByte[10] = $tmp;		$tmp = $Sbox[$_stateByte[6]]; $_stateByte[6] = $Sbox[$_stateByte[14]]; $_stateByte[14] = $tmp;			// rotate row 3		$tmp = $Sbox[$_stateByte[15]]; $_stateByte[15] = $Sbox[$_stateByte[11]];		$_stateByte[11] = $Sbox[$_stateByte[7]]; $_stateByte[7] = $Sbox[$_stateByte[3]]; $_stateByte[3] = $tmp;			}		// restores columns in each of 4 rows	// row0 - unchanged, row1- shifted right 1, 	// row2 - shifted right 2 and row3 - shifted right 3	protected function invShiftRows ()	{		$tmp = 0;			$_stateByte = $this->_stateByte;		$InvSbox = AESKeyInclude::$_InvSbox;		// restore row 0		$_stateByte[0] = $InvSbox[$_stateByte[0]]; $_stateByte[4] = $InvSbox[$_stateByte[4]];		$_stateByte[8] = $InvSbox[$_stateByte[8]]; $_stateByte[12] = $InvSbox[$_stateByte[12]];			// restore row 1		$tmp = $InvSbox[$_stateByte[13]]; $_stateByte[13] = $InvSbox[$_stateByte[9]];		$_stateByte[9] = $InvSbox[$_stateByte[5]]; $_stateByte[5] = $InvSbox[$_stateByte[1]]; $_stateByte[1] = $tmp;			// restore row 2		$tmp = $InvSbox[$_stateByte[2]]; $_stateByte[2] = $InvSbox[$_stateByte[10]]; $_stateByte[10] = $tmp;		$tmp = $InvSbox[$_stateByte[6]]; $_stateByte[6] = $InvSbox[$_stateByte[14]]; $_stateByte[14] = $tmp;			// restore row 3		$tmp = $InvSbox[$_stateByte[3]]; $_stateByte[3] = $InvSbox[$_stateByte[7]];		$_stateByte[7] = $InvSbox[$_stateByte[11]]; $_stateByte[11] = $InvSbox[$_stateByte[15]]; $_stateByte[15] = $tmp;				$this->_stateByte = $_stateByte;	}		// recombine and mix each row in a column	protected function mixSubColumns ()	{		$_tempByte = array();//.length=0;		$Xtime2Sbox = AESKeyInclude::$_Xtime2Sbox;		$Xtime3Sbox = AESKeyInclude::$_Xtime3Sbox;		$_stateByte = &$this->_stateByte;		$Sbox = AESKeyInclude::$_Sbox;		// mixing column 0		$_tempByte[0] = $Xtime2Sbox[$_stateByte[0]] ^ $Xtime3Sbox[$_stateByte[5]] ^ $Sbox[$_stateByte[10]] ^ $Sbox[$_stateByte[15]];		$_tempByte[1] = $Sbox[$_stateByte[0]] ^ $Xtime2Sbox[$_stateByte[5]] ^ $Xtime3Sbox[$_stateByte[10]] ^ $Sbox[$_stateByte[15]];		$_tempByte[2] = $Sbox[$_stateByte[0]] ^ $Sbox[$_stateByte[5]] ^ $Xtime2Sbox[$_stateByte[10]] ^ $Xtime3Sbox[$_stateByte[15]];		$_tempByte[3] = $Xtime3Sbox[$_stateByte[0]] ^ $Sbox[$_stateByte[5]] ^ $Sbox[$_stateByte[10]] ^ $Xtime2Sbox[$_stateByte[15]];			// mixing column 1		$_tempByte[4] = $Xtime2Sbox[$_stateByte[4]] ^ $Xtime3Sbox[$_stateByte[9]] ^ $Sbox[$_stateByte[14]] ^ $Sbox[$_stateByte[3]];		$_tempByte[5] = $Sbox[$_stateByte[4]] ^ $Xtime2Sbox[$_stateByte[9]] ^ $Xtime3Sbox[$_stateByte[14]] ^ $Sbox[$_stateByte[3]];		$_tempByte[6] = $Sbox[$_stateByte[4]] ^ $Sbox[$_stateByte[9]] ^ $Xtime2Sbox[$_stateByte[14]] ^ $Xtime3Sbox[$_stateByte[3]];		$_tempByte[7] = $Xtime3Sbox[$_stateByte[4]] ^ $Sbox[$_stateByte[9]] ^ $Sbox[$_stateByte[14]] ^ $Xtime2Sbox[$_stateByte[3]];			// mixing column 2		$_tempByte[8] = $Xtime2Sbox[$_stateByte[8]] ^ $Xtime3Sbox[$_stateByte[13]] ^ $Sbox[$_stateByte[2]] ^ $Sbox[$_stateByte[7]];		$_tempByte[9] = $Sbox[$_stateByte[8]] ^ $Xtime2Sbox[$_stateByte[13]] ^ $Xtime3Sbox[$_stateByte[2]] ^ $Sbox[$_stateByte[7]];		$_tempByte[10]  = $Sbox[$_stateByte[8]] ^ $Sbox[$_stateByte[13]] ^ $Xtime2Sbox[$_stateByte[2]] ^ $Xtime3Sbox[$_stateByte[7]];		$_tempByte[11]  = $Xtime3Sbox[$_stateByte[8]] ^ $Sbox[$_stateByte[13]] ^ $Sbox[$_stateByte[2]] ^ $Xtime2Sbox[$_stateByte[7]];			// mixing column 3		$_tempByte[12] = $Xtime2Sbox[$_stateByte[12]] ^ $Xtime3Sbox[$_stateByte[1]] ^ $Sbox[$_stateByte[6]] ^ $Sbox[$_stateByte[11]];		$_tempByte[13] = $Sbox[$_stateByte[12]] ^ $Xtime2Sbox[$_stateByte[1]] ^ $Xtime3Sbox[$_stateByte[6]] ^ $Sbox[$_stateByte[11]];		$_tempByte[14] = $Sbox[$_stateByte[12]] ^ $Sbox[$_stateByte[1]] ^ $Xtime2Sbox[$_stateByte[6]] ^ $Xtime3Sbox[$_stateByte[11]];		$_tempByte[15] = $Xtime3Sbox[$_stateByte[12]] ^ $Sbox[$_stateByte[1]] ^ $Sbox[$_stateByte[6]] ^ $Xtime2Sbox[$_stateByte[11]];			/*		_stateByte.position=0;		_stateByte.writeBytes(_tempByte, 0, Nb*4);*/				$_stateByte = $_tempByte;				$this->_tempByte = $_tempByte;	}		// restore and un-mix each row in a column	protected function invMixSubColumns ()	{		$_tempByte = array();//.length=0;		$_stateByte = &$this->_stateByte;		$XtimeE = AESKeyInclude::$_XtimeE;		$XtimeB = AESKeyInclude::$_XtimeB;		$Xtime9 = AESKeyInclude::$_Xtime9;		$XtimeD = AESKeyInclude::$_XtimeD;		$InvSbox = AESKeyInclude::$_InvSbox;		$Nb = AESKeyInclude::$Nb;				// restore column 0		$_tempByte[0] = $XtimeE[$_stateByte[0]] ^ $XtimeB[$_stateByte[1]] ^ $XtimeD[$_stateByte[2]] ^ $Xtime9[$_stateByte[3]];		$_tempByte[5] = $Xtime9[$_stateByte[0]] ^ $XtimeE[$_stateByte[1]] ^ $XtimeB[$_stateByte[2]] ^ $XtimeD[$_stateByte[3]];		$_tempByte[10] = $XtimeD[$_stateByte[0]] ^ $Xtime9[$_stateByte[1]] ^ $XtimeE[$_stateByte[2]] ^ $XtimeB[$_stateByte[3]];		$_tempByte[15] = $XtimeB[$_stateByte[0]] ^ $XtimeD[$_stateByte[1]] ^ $Xtime9[$_stateByte[2]] ^ $XtimeE[$_stateByte[3]];			// restore column 1		$_tempByte[4] = $XtimeE[$_stateByte[4]] ^ $XtimeB[$_stateByte[5]] ^ $XtimeD[$_stateByte[6]] ^ $Xtime9[$_stateByte[7]];		$_tempByte[9] = $Xtime9[$_stateByte[4]] ^ $XtimeE[$_stateByte[5]] ^ $XtimeB[$_stateByte[6]] ^ $XtimeD[$_stateByte[7]];		$_tempByte[14] = $XtimeD[$_stateByte[4]] ^ $Xtime9[$_stateByte[5]] ^ $XtimeE[$_stateByte[6]] ^ $XtimeB[$_stateByte[7]];		$_tempByte[3] = $XtimeB[$_stateByte[4]] ^ $XtimeD[$_stateByte[5]] ^ $Xtime9[$_stateByte[6]] ^ $XtimeE[$_stateByte[7]];			// restore column 2		$_tempByte[8] = $XtimeE[$_stateByte[8]] ^ $XtimeB[$_stateByte[9]] ^ $XtimeD[$_stateByte[10]] ^ $Xtime9[$_stateByte[11]];		$_tempByte[13] = $Xtime9[$_stateByte[8]] ^ $XtimeE[$_stateByte[9]] ^ $XtimeB[$_stateByte[10]] ^ $XtimeD[$_stateByte[11]];		$_tempByte[2]  = $XtimeD[$_stateByte[8]] ^ $Xtime9[$_stateByte[9]] ^ $XtimeE[$_stateByte[10]] ^ $XtimeB[$_stateByte[11]];		$_tempByte[7]  = $XtimeB[$_stateByte[8]] ^ $XtimeD[$_stateByte[9]] ^ $Xtime9[$_stateByte[10]] ^ $XtimeE[$_stateByte[11]];			// restore column 3		$_tempByte[12] = $XtimeE[$_stateByte[12]] ^ $XtimeB[$_stateByte[13]] ^ $XtimeD[$_stateByte[14]] ^ $Xtime9[$_stateByte[15]];		$_tempByte[1] = $Xtime9[$_stateByte[12]] ^ $XtimeE[$_stateByte[13]] ^ $XtimeB[$_stateByte[14]] ^ $XtimeD[$_stateByte[15]];		$_tempByte[6] = $XtimeD[$_stateByte[12]] ^ $Xtime9[$_stateByte[13]] ^ $XtimeE[$_stateByte[14]] ^ $XtimeB[$_stateByte[15]];		$_tempByte[11] = $XtimeB[$_stateByte[12]] ^ $XtimeD[$_stateByte[13]] ^ $Xtime9[$_stateByte[14]] ^ $XtimeE[$_stateByte[15]];			for( $i=0; $i _stateByte;		for( $idx = 0; $idx _keyLength);	}}?>
Salin selepas log masuk


<?phprequire_once ("IMode.php");require_once("ICipher.php");require_once("ISymmetricKey.php");require_once("PKCS5.php");class ECBMode implements IMode{	private $_key;	private $_padding;		public function ECBMode($key/*:ISymmetricKey*/, $padding/*:IPad*/ = NULL) 	{		$this->_key = $key;		if ($padding == NULL) {			$padding = new PKCS5($key->getBlockSize());		} else {			$padding->setBlockSize($key->getBlockSize());		}		$this->_padding = $padding;	}		public function getBlockSize() {		return $this->_key->getBlockSize();	}		public function encrypt($src) 	{		$src = $this->_padding->pad($src);		$blockSize = $this->_key->getBlockSize();		$dst = array();		$len = count($src);		for ($i=0;$i_key->encrypt($tmp);			$dst = array_merge($dst,$ret);		}		return $dst;	}		public function decrypt($src) 	{		$blockSize = $this->_key->getBlockSize();				$len = count($src);		// sanity check.		if ($len % $blockSize!=0) {			throw new Exception("ECB mode cipher length must be a multiple of blocksize ".$blockSize);		}				$tmp = array();		$dst = array();				for ($i=0;$i_key->decrypt($tmp);			$dst = array_merge($dst,$ret);		}		$dst = $this->_padding->unpad($dst);		return $dst;	}		public function dispose() 	{			}		public function toString() {		return $this->_key->toString()."-ecb";	}}?>
Salin selepas log masuk



<?phpclass Hex{	static function string2ByteArray($src)	{		//$hex = bin2hex($src);		$ret = array();		$len = strlen($src);		for($i = 0; $i<$len; ++$i)		{			$ret[] = ord($src[$i]);		}		return $ret;	}		static function byteArray2String($src)	{		$ret = "";		$len = count($src);		for($i = 0; $i<$len; ++$i)		{			$ret .= chr($src[$i]);		}				return $ret;	}}?>
Salin selepas log masuk



<?phpinterface ICipher{	function getBlockSize();	function encrypt($src);	function decrypt($src);	function dispose();	function toString();}?>
Salin selepas log masuk



<?phprequire_once ("ICipher.php");interface IMode extends ICipher{}?>
Salin selepas log masuk



<?phpinterface IPad{	/**	 * Add padding to the array	 */	function pad($a);	/**	 * Remove padding from the array.	 * @throws Error if the padding is invalid.	 */	function unpad($a);	/**	 * Set the blockSize to work on	 */	function setBlockSize($bs);}?>
Salin selepas log masuk


<?phpinterface ISymmetricKey{	/**	 * Returns the block size used by this particular encryption algorithm	 */	function getBlockSize();	/**	 * Encrypt one block of data in "block", starting at "index", of length "getBlockSize()"	 */	function encrypt($block, $index);	/**	 * Decrypt one block of data in "block", starting at "index", of length "getBlockSize()"	 */	function decrypt($block, $index);	/**	 * Attempts to destroy sensitive information from memory, such as encryption keys.	 * Note: This is not guaranteed to work given the Flash sandbox model.	 */	function dispose();		function toString();}?>
Salin selepas log masuk
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn

Alat AI Hot

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

AI Hentai Generator

AI Hentai Generator

Menjana ai hentai secara percuma.

Artikel Panas

R.E.P.O. Kristal tenaga dijelaskan dan apa yang mereka lakukan (kristal kuning)
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Tetapan grafik terbaik
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Cara Memperbaiki Audio Jika anda tidak dapat mendengar sesiapa
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Cara Membuka Segala -galanya Di Myrise
4 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌

Alat panas

Notepad++7.3.1

Notepad++7.3.1

Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina

SublimeText3 versi Cina

Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1

Hantar Studio 13.0.1

Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6

Dreamweaver CS6

Alat pembangunan web visual

SublimeText3 versi Mac

SublimeText3 versi Mac

Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Apakah maksud fungsi? Apakah maksud fungsi? Aug 04, 2023 am 10:33 AM

Fungsi bermaksud fungsi. Ia adalah blok kod yang boleh digunakan semula dengan fungsi tertentu Ia boleh menerima parameter input, melakukan operasi tertentu, dan mengembalikan hasil daripada blok yang boleh digunakan semula. kod untuk meningkatkan kebolehgunaan semula dan kebolehselenggaraan kod.

Penjelasan terperinci tentang peranan dan fungsi jadual MySQL.proc Penjelasan terperinci tentang peranan dan fungsi jadual MySQL.proc Mar 16, 2024 am 09:03 AM

Penjelasan terperinci tentang peranan dan fungsi jadual MySQL.proc ialah sistem pengurusan pangkalan data relasi yang popular Apabila pembangun menggunakan MySQL, mereka sering melibatkan penciptaan dan pengurusan prosedur tersimpan (StoredProcedure). Jadual MySQL.proc ialah jadual sistem yang sangat penting Ia menyimpan maklumat yang berkaitan dengan semua prosedur tersimpan dalam pangkalan data, termasuk nama, definisi, parameter, dsb. prosedur tersimpan. Dalam artikel ini, kami akan menerangkan secara terperinci peranan dan kefungsian jadual MySQL.proc

Apakah tujuan fungsi 'enumerate()' dalam Python? Apakah tujuan fungsi 'enumerate()' dalam Python? Sep 01, 2023 am 11:29 AM

Dalam artikel ini, kita akan belajar tentang fungsi enumerate() dan tujuan fungsi "enumerate()" dalam Python. Apakah fungsi enumerate()? Fungsi enumerate() Python menerima pengumpulan data sebagai parameter dan mengembalikan objek penghitungan. Objek penghitungan dikembalikan sebagai pasangan nilai kunci. Kuncinya ialah indeks yang sepadan dengan setiap item, dan nilainya ialah item. Syntax enumerate(iterable,start) Parameters iterable - Yang diluluskan dalam pengumpulan data boleh dikembalikan sebagai objek enumeration, dipanggil iterablestart - Seperti namanya, indeks permulaan objek enumeration ditakrifkan oleh permulaan. kalau kita abaikan

Penggunaan dan fungsi fungsi Vue.use Penggunaan dan fungsi fungsi Vue.use Jul 24, 2023 pm 06:09 PM

Penggunaan dan Fungsi Fungsi Vue.use Vue ialah rangka kerja bahagian hadapan yang popular yang menyediakan banyak ciri dan fungsi berguna. Salah satunya ialah fungsi Vue.use, yang membolehkan kami menggunakan pemalam dalam aplikasi Vue. Artikel ini akan memperkenalkan penggunaan dan fungsi fungsi Vue.use dan memberikan beberapa contoh kod. Penggunaan asas fungsi Vue.use adalah sangat mudah, cuma panggilnya sebelum Vue diwujudkan, menghantar pemalam yang anda ingin gunakan sebagai parameter. Berikut ialah contoh mudah: //Perkenalkan dan gunakan pemalam

Apakah kegunaan fungsi js Apakah kegunaan fungsi js Oct 07, 2023 am 11:25 AM

Penggunaan fungsi fungsi js ialah: 1. Fungsi Isytihar; 3. Parameter fungsi; 5. Fungsi tanpa nama;

file_exists() fungsi dalam PHP file_exists() fungsi dalam PHP Sep 14, 2023 am 08:29 AM

Kaedah file_exists menyemak sama ada fail atau direktori wujud. Ia menerima sebagai hujah laluan fail atau direktori untuk diperiksa. Inilah kegunaannya - ia berguna apabila anda perlu mengetahui sama ada fail wujud sebelum memprosesnya. Dengan cara ini, apabila mencipta fail baharu, anda boleh menggunakan fungsi ini untuk mengetahui sama ada fail itu sudah wujud. Syntax file_exists($file_path) Parameter file_path - Tetapkan laluan fail atau direktori untuk disemak kewujudan. Diperlukan. Kembalikan kaedah file_exists() kembali. Mengembalikan TrueFalse jika fail atau direktori wujud, jika fail atau direktori tidak wujud Contoh mari kita lihat semakan untuk fail "candidate.txt" dan walaupun fail

clearstatcache() fungsi dalam PHP clearstatcache() fungsi dalam PHP Sep 07, 2023 am 09:33 AM

Fungsi clearstatcache() digunakan untuk mengosongkan cache status fail. PHP menyimpan cache maklumat yang dikembalikan oleh fungsi berikut −stat()lstat()file_exists()is_writable()is_readable()is_executable()is_file()is_dir()filegroup()fileowner()filesize()filetype()fileperms() Apakah untuk melakukan Untuk memberikan prestasi yang lebih baik. Sintaks voidclearstatecache() Parameter NA Nilai pulangan clearstatcache(

Cara menggunakan fungsi SOA dalam PHP Cara menggunakan fungsi SOA dalam PHP May 18, 2023 pm 01:10 PM

Dengan perkembangan Internet, SOA (seni bina berorientasikan perkhidmatan) telah menjadi seni bina teknikal yang penting dalam sistem peringkat perusahaan hari ini. Perkhidmatan dalam seni bina SOA boleh digunakan semula, disusun semula dan diperluaskan, di samping memudahkan proses pembangunan dan penyelenggaraan sistem. Sebagai bahasa pengaturcaraan Web yang digunakan secara meluas, PHP juga menyediakan beberapa perpustakaan fungsi untuk melaksanakan SOA. Seterusnya, kami akan memperincikan cara menggunakan fungsi SOA dalam PHP. 1. Konsep asas SOA ialah idea dan seni bina sistem teragih.

See all articles