Latest article

How to solve the php encryption garbled problem-PHP problem

The solution to php encrypted garbled characters: first encrypt the ciphertext with MD5; then use base64 encryption to avoid garbled characters, the code statement is “$bs_test = base64_encode($test);”. Recommendation: “PHP Video Tutorial” In recent projects, It is to encapsulate the original function into an interface for third-party calls. Among them, it comes into contact with the signature encryption, which uses RES encryption. The idea is to use the public key and POST parameters to form a string and then perform public key encryption. However, RES encryption requires ciphertext and has a length limit. If the POST data is too long, the ciphertext data will be too long, and decryption will fail. Therefore, our solution to this problem is to encrypt the ciphertext with MD5, and then encrypt the encrypted data with RES. However, the RES-encrypted data may also be Encoding problems lead to garbled characters, so we also need to perform base64 encryption to avoid garbled characters. The simple code is shown below: /* *$rsa_pub is the RES public key * */ $secret = md5($querystr . $api_secret); //Composition of ciphertext openssl_public_encrypt($secret ,$test, $rsa_pub); //public key encryption $bs_test = base64_encode($test); //Encrypt base64 The above is the detailed content of how to…

How to solve the problem of garbled characters in phpget parameters-PHP problem

The solution to garbled characters in php get parameters: 1. Use the “iconv(“gb2312″,”UTF-8″,$gonghui);” method to solve the problem of garbled characters; 2. Use the method “mb_convert_encoding” to solve the problem of garbled characters . Recommendation: “PHP Video Tutorial” PHP uses the get method to get Chinese garbled characters from the URL strong> The following are two methods The first method uses $gOnghui= iconv(“gb2312″,”UTF-8”,$gonghui); The second method ** * Multi-byte string encoding conversion function * * @param string str The string that needs to be encoded and converted * @param string to_encoding specifies conversion to a certain encoding, such as: gb2312, gbk, utf-8, etc. * @param mixed from_encoding Mixed specify the encoding of the original string, such as: specify JIS, eucjp-win, sjis-win mixed encoding at the same time * @return string string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] ) **/ The mb_convert_encoding function is an internal multi-byte string encoding conversion function in php, which can support almost all encodings when necessary. PHP >= 4.0.6, 5 version support. Direct access to reg.php?gh=someone; //Trade union login parameters $gOnghui= $_GET['gh']; The obtained $gonghui is gb2312 encoded and output to utf-8 webpage to display garbled characters Change to p> // Union login…

How does php regularize not contain a certain string-PHP problem

The method of php regular not containing a certain string: first create a PHP sample file; then pass the regular expression “preg_match(“/[^(abc)]/s”, $str, $arr); “It is enough to realize that the judgment does not contain a certain string. //——————- —————————– code show as below: //———————————————— The result is: false, contains abc! $str = “2b3c4d5c”; Note: [^(abc)] This syntax is to check whether the characters in $str are not in a b c one by one, preg_match(“/[^(abc)]/s”, $str, $arr); The character 2 is not in a b c, so the return value of $arr is 2; Matches both, contains the string “abc” and does not contain the string “xyz” “/(abc)[^((?!xyz).)*$]/s” The following is a supplement: Judging a string There are many ways to check whether there is another string in it, as follows: 1. Common functions strstr($str, “abc “); 2. Regular match preg_match(“/(abc)/is”, $str); But to match a string that does not contain a certain string, it is more troublesome to use regular expressions. 1. If you don’t use regular rules, you can solve the problem as follows !strstr($str, “abc”); 2. But with regular expressions, that’s all there is to it preg_match(“/^((?!abc).)*$/is”, $str ); Complete code example The code is as…

How does iis hide index.php-PHP problem

How to hide index.php in iis: first install the URL Rewrite module of Microsoft; then click the url rewrite module, and click “Import Rules”; finally fill in the rewrite rules, and click “Apply” . RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} ! -f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] The above is how iis hides the details of index.php, please pay attention to other related articles on 1024programmer.com for more!

How to solve the problem of garbled characters in php reading files-PHP problem

The solution to php reading garbled characters: first open the corresponding code file; then use the “iconv($encodType, “utf-8″, $content);” method to solve the Chinese garbled characters. Recommendation: “PHP Video Tutorial” PHP reads files , Solve Chinese garbled UTF-8 $opts = array( ‘file’ => array( ‘encoding’ => “utf-8” ) ); $opts = array('http' => array('encoding' => 'utf-8')); $ctxt = stream_context_create($opts); $cOntent= file_get_contents($filePath, FILE_TEXT, $ctxt); The easiest way is to add GF2312→UTF-8 $ str=iconv(“gb2312”, “utf-8”, $str); It doesn’t work $cOntent= mb_convert_encoding ( $content , “UTF-8” , “auto” ); ******************************************** *Ugly dividing line to tell everyone the bad above: the following is the correct way···haha··********************** ******************************************* define('UTF32_BIG_ENDIAN_BOM', chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF)); define('UTF32_LITTLE_ENDIAN_BOM', chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00)); define('UTF16_BIG_ENDIAN_BOM', chr(0xFE) . chr(0xFF)); define('UTF16_LITTLE_ENDIAN_BOM', chr(0xFF) . chr(0xFE)); define('UTF8_BOM', chr(0xEF) . chr(0xBB) . chr(0xBF)); $text = file_get_contents($newPath); $first2 = substr($text, 0, 2); $first3 = substr($text, 0, 3); $first4 = substr($text, 0, 3); $encodType = “”; if ($first3 == UTF8_BOM) $encodType = 'UTF-8 BOM'; else if ($first4 == UTF32_BIG_ENDIAN_BOM) $encodType = 'UTF-32BE'; else if ($first4 == UTF32_LITTLE_ENDIAN_BOM) $encodType = 'UTF-32LE'; else if ($first2 == UTF16_BIG_ENDIAN_BOM) $encodType = 'UTF-16BE'; else if ($first2 == UTF16_LITTLE_ENDIAN_BOM) $encodType = 'UTF-16LE'; $cOntent= file_get_contents($newPath); $cOntent= iconv($encodType, “utf-8”, $content);…

What should I do if phpsession cannot get the value – PHP problem

The php session cannot get the value because the session is not passed in. The solution is to open the session through the “session_start()” method before using the php session. Recommendation: “PHP Video Tutorial” I recently encountered a problem when writing PHP This problem, the session will always exist when the entire website is not closed, but after the session is initialized on one page, I can’t get the session value on another page, and I use echo to print the session information and find that it is not passed in at all. session, I thought it was another usage of php session. . . (っ°Д °;)っ, I only used sessions in Asp and Jsp before, and finally found the cause of the error. The php session must be opened before use: session_start() This statement should be placed in front of all statements that use session, so it is best to write it at the front of the php file, so as not to forget, this is used with other languages There is a little difference in the session. In addition, there are several useful functions about the use of the php session, for example: isset($ _SESSION['view']) // Determine whether…

How to modify xml in php-PHP problem

How to modify xml in php: first create a code sample file; then modify the node value through the “$new->nodeValue=$_content;” method. Recommendation: “PHP Video Tutorial” php create, add, delete, modify xml Create xml method: formatOutput = true; $root = $doc -> createElement('root');//New node $index = $doc -> createElement('index');//New node $url = $doc -> createAttribute('url');//Create a new attribute $patch = $doc -> createTextNode($_htmlpatch);//New TEXT value $url -> appendChild($patch);//Set the $patch text to the value of the $url attribute $id = $doc -> createAttribute('id'); $newsid = $doc -> createTextNode($_id); $id -> appendChild($newsid); $title = $doc -> createAttribute('title'); $newstitle = $doc -> createTextNode($_title); $title -> appendChild($newstitle); $cOntent= $doc -> createTextNode($_content);//node value $author = $doc -> createAttribute('author'); $newsauthor = $doc -> createTextNode($_author); $author -> appendChild($newsauthor); $sendtime = $doc -> createAttribute('time'); $newssendtime = $doc -> createTextNode($_sendtime); $sendtime -> appendChild($newssendtime); $index -> appendChild($id);//Set $id as the attribute of the index node, the following are similar $index -> appendChild($title); $index -> appendChild($content); $index -> appendChild($url); $index -> appendChild($author); $index -> appendChild($sendtime); $root -> appendChild($index);//Set index to root node $doc -> appendChild($root);//Set root as the root node $doc -> save($xmlpatch);//Save the file echo $xmlpatch . & # 39; has create success & # 39;; ?> Add xml nodes…

The solution to the problem that php cannot display pictures-PHP problem

PHP cannot display pictures because there are other outputs besides img output in the source code. The solution is to cancel any output before the header is called. Recommendation: “PHP Video Tutorial” Specific questions: The php file can output pictures but cannot display them! Use imagegif($image,&#39 ;verify.php'); echo ; You can output pictures. But change to header ( “content-type:image/gif” ); imagegif($image); can output pictures. But it doesn’t show up. The file reports no errors. Solve, how can it be displayed. . . . Solved. Add ob_end_clean() in the first line; I’m entangled with the dead Solution: After testing, both methods can be displayed correctly. It is estimated that the reason why your second method cannot be displayed normally is: In the second method, you have other outputs besides img output . Please see the sample code below: Why the second method cannot have content in front of the header. For the reason, please refer to the following explanation: header() must be in Called before any actual output, whether it is an ordinary html tag, or a blank line or space in a file, or a blank line or space in a PHP file. A simple sentence: there will be an…

Where is the php training school-PHP problem

Where is the php training school? Now more and more people choose to train PHP, and the reason is obvious, because PHP is simple, has a short development cycle, and runs fast, and has become the preferred technology for small and medium-sized websites! So if you want to find a school or institution to train PHP technology, you have to keep your eyes open! Some people pay more attention to the environment when they choose an IT school. I personally think that when we choose an IT school, the environment is only one aspect. We should pay more attention to the school’s culture, study Atmosphere~ If we are in a school with a loose school spirit, we will inevitably become playful and lazy. If we are in a school with a strong learning atmosphere, we will strictly demand ourselves, speak and act prudently, study hard, and over time we will become a good student who has made progress in all aspects. A good campus culture and learning atmosphere can infect you and let you and your classmates work together~ Remember, the environment cannot be taken away, and learning professional skills is hard reason! So field trips to schools are crucial!…

How about Wendou PHP training-PHP problem

Now there are more and more PHP training institutions on the market. I believe everyone is more curious about some institutions. Here is a brief introduction to the Dou PHP training below. Wendou IT Training is a skills training college under Wendou Group with professional IT technology strength. It was established in 2009. The training department is located in Lujiang, Haizhu District, Guangzhou, close to the subway Lujiang Station on Line 8, with convenient transportation. Wendou IT’s training programs mainly include: PHP programming development, plane, web page, UI design, HTML5 mobile terminal, network marketing courses, etc. Wendou Group is a high-tech group company providing Internet services. It integrates planning, design, front-end optimization, research and development, testing, system operation and maintenance, website promotion, operation, team outsourcing and Internet talent training. Integrated mature business system. Wendou Network mainly provides high-quality website construction solutions, mobile application development solutions (based on Android, iOS APP and mobile website), micro-applications, micro-malls, micro-official websites, and micro-interactive marketing solutions. Enterprise information solutions (OA, CRM), as well as PHP website development, Java development, UI design, Taobao art talent training services, talent outsourcing services, high-end IT talent headhunting services. Note: 1024programmer.com provides a large number of free, original, high-definition php…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索