PHP verification code image cannot be output, how to solve it-php tutorial
The PHP verification code image cannot be outputFile name global_func.php PHP code http://www.CodeHighlighter.com/–>function _code(){/ /Run verification code//Number of random codes $_rnd_code=4; for($i=0;$i<$_rnd_code;$i++){ $_nmsg.=dechex(mt_rand(0, 15)); } //Save In session $_SESSION['code']=$_nmsg; //Length and height$_width=75; $_height=25; //Create an image$_img=imagecreatetruecolor($_width,$_height); //White $_white=imagecolorallocate($_img, 255, 255, 255); //Fill imagefill($_img, 0, 0, $_white); $_flag=false; if($_flag){ //Black, border$_black= imagecolorallocate($_img, 0,0,0); imagerectangle($_img, 0,0, $_width-1,$_height-1,$_black); } //Draw 6 lines for($i=0; $i<6;$i++){ $_rnd_color=imagecolorallocate($_img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imageline($_img,mt_rand(0,$_width),mt_rand(0, $_height),mt_rand(0,$_width),mt_rand(0,$_height), $_rnd_color); } //Snowflake for($i;$i<100;$i++){ $_rnd_color=imagecolorallocate($_img ,mt_rand(200,255), mt_rand(200,255), mt_rand(200,255)); imagestring($_img,1, mt_rand(1, $_width),mt_rand(1,$_height), '*', $_rnd_color); } / /Output verification code for($i=0;$i<strlen($_SESSION['code']);$i++){ $_rnd_color=imagecolorallocate($_img, mt_rand(0, 100), mt_rand(0, 150) , mt_rand(0, 200)); imagestring($_img,5,$i*$_width/$_rnd_code+mt_rand(1,10), mt_rand(1,$_height/2),$_SESSION['code'][ $i],$_rnd_color); } //Output image header('Content-Type:image/png'); imagepng($_img); //Destroy imagedestroy($_img);} If I call function _code(); in the global_func.php file, an error will appear and a red cross will appear. code.php PHP code http://www.CodeHighlighter.com/–>_code(); This can be used if I write it directly in code.php. code.php PHP code http://www.CodeHighlighter.com/–> //Number of random codes $_rnd_code=4; for( $i=0;$i<$_rnd_code;$i++){ $_nmsg.=dechex(mt_rand(0, 15)); } //Save in session $_SESSION['code']=$_nmsg; //Long and height $_width=75; $_height=25; //Create an image $_img=imagecreatetruecolor($_width,$_height); //White $_white=imagecolorallocate($_img, 255, 255, 255); // Fill imagefill($_img, 0, 0, $_white); $_flag=false; if($_flag){ //Black, border $_black=imagecolorallocate($_img, 0,0,0); imagerectangle($_img, 0,0, $_width-1,$_height-1,$_black); } //Draw 6 lines for($i=0;$i<6;$i++){ $_rnd_color=imagecolorallocate($_img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); imageline($_img,mt_rand(0,$_width),mt_rand(0,$_height),mt_rand(0,$_width),mt_rand(0,$ _height), $_rnd_color); } //Snowflake for($i;$i<100;$i++){…
Regular way to extract video path, how to solve it-php tutorial
Regularly, extract the video pathFor example, a string It may be a paragraph in an article and there is probably something at the end I want to add the above The script is extracted, the red part above. In addition, I also want to extract the video parameters in the script, such as length, width and path. For example550, 400, http://player.56.com/v_NTYwMzg0MjA.swf But I don’t understand regular rules, please help me. ——Solution——————– PHP code $s=<<$('swf_6Z5').innerHTML=AC_FL_RunContent('width', '550', 'height', '400', 'allowNetworking' , 'internal', 'allowScriptAccess', 'never', 'src', 'http://player.56.com/v_NTYwMzg0MjA.swf', 'quality', 'high', 'bgcolor', '#ffffff', 'wmode', 'transparent', 'allowfullscreen', 'true'); There is probably html at the end; preg_match_all("//isU",$s,$m); print_r($m);
PHP reads txt content according to conditions, how to solve it – PHP tutorial
PHP reads txt content according to conditionsI now have a notepad with the content: articles The research articles in all journals published by BioPublisher are ‘Open Access’. They are immediately and permanently available online without charge. A number of journals require an institutional or a personal subscription to view other content, such as reviews or paper reports. Free trial subscriptions to these journals are available. about tel:** ************************ address:**************************** ********* I am now using PHP to read this notepad, because there are good paragraphs in it, and there is a title before each paragraph. Now I want to read through the previous title. produce different content. Please give advice from experts. ——Solution——————–The logic is incorrect, [email protected]Modify as follows: PHP code <?php$file_name="dir.txt";$fp =fopen($file_name,'r');while(!feof($fp)) //Read all the files{ $buffer=fgets($fp); //Get a line, do not add length if(preg_match(' /\s*@/i', $buffer)){// Use regular echo "This is title”; echo $buffer.””; }else{ echo “This is body” ; echo $buffer.””; }}fclose($fp); //Close the file stream?>——Solution— ——————[email protected], use this to separate, note that @ should be in the top space PHP code $find = ‘about’; //The title you are looking for $file_name=”dir.txt”; $fp=fopen($file_name,’r’);$title = ”;$cOntent= ”;while($buffer = fgets($fp,1024)) //The file does not have to be read { if($buffer{0}…
Looking for a paper + source code on experimental equipment management system in PHP language, how to solve it – PHP tutorial
Looking for a paper + source code on an experimental equipment management system in PHP languageI am a senior student majoring in computer science. I am about to graduate and my graduation project has not yet been released, so I am asking you all to help me get one. Graduation project should preferably be your graduation work. I would be very grateful. ——Solution——————–Your old man is really rich
Thief program, how to solve it-php tutorial
Thief ProgramHow to get the Thief Program? I want this website http://www.weather.com.cn/weather/101010100.shtml () The content in brackets. Just keep it simple. . . It doesn’t have to be too complicated ——Solution——————- –file_get_contents, preg_match
PHP login page, how to solve it – PHP tutorial
php login page<?phpinclude(‘conn.php’);session_start();if(isset(‘$_post[submit]’)){ $sql=”select * from chen where name=’$_post[user]’ and ‘$_post[pwd]’”; $rs=mysql_query($sql); $row= mysql_fetch_array($rs); if($row){ 《 $time=time()+3600; $_session[user]=(“zhangsan”,time ()+3600); $_session[pwd]=”zhangsan”,1); $_session[]=(“longin.php”,true,$time);》 header(“location:index.php”);?>Log in again Login page Username: Password: User login: Please show me how to write it and convert the page ——Solution— —————— PHP code //This variable is within single quotes, so it is not will be parsed and only treated as a string. isset() accepts a variable if(isset(‘$_post[submit]’)){// The key value replaced by $_POST is a string type, so use ‘submit’if(isset($_POST[‘ submit’] ){// There is no Chinese ” in front, otherwise a syntax error will be reported ” $time=time()+3600;// (“zhangsan”, time()+3600) is not an expression and does not return Value. Variables are also case-sensitive $_session[user]=(“zhangsan”,time()+3600);// Replace with $_SESSION[‘user’] = ‘zhangsan’;// If you want to set the life of the session Period, you need to set session.COOKIE_lifetime in php.ini. But if you don’t have a good foundation, don’t rush it yet——Solution—– —————One is quotation marks, and the other is POST and GET, which should be capitalized.——Solution——————–What he means is that you can set the default COOKIE storage time, The SESSION ID is generally stored in the COOKIE, so once the COOKIE ends, your SESSION is gone
Looking for a simple regular rule, how to solve it-php tutorial
Looking for a simple regular expression$str=”12345…”;Now I just want to replace the above The character “三四” displayed on the page in the string is replaced with “三四”, while the characters in the hypertext tag remain unchanged. The replacement result is as follows:$str=”一二三四五…”;How to write this statement? Thank you ——Solution——————– PHP code $str=”one two three four five one two three four five one two three four five one two three four five\n…”;echo preg_replace(‘/三四(?![^)/’,’三四’, $str);
Smarty3.0 custom function, how to solve it-php tutorial
Smarty3.0 custom functionThe program runs without problems, but prompts: Notice: function call ‘register_function’ is unknown or deprecated. in E:\webphp\Smarty\sysplugins\smarty_internal_wrapper.php on line 57 Here is the registration function $smarty->register_function(‘list’,’format_data’); Other information I found said that this is a feature of smarty2.0, I use it now It is 3.0. How to solve this problem? Please give some advice. ——Solution——————–3.0 has used another method to replace it,To create a new file name method under smarty/libs/pluginsReference address http://www.gxcxy.com/thread-5259 -1-1.htmlYou can take a look——Solution————— —–Attention, haha——Solution———— ——–3.0 will report an error because the core library has deleted this method, but this method can still be used normally, [email protected]: @$smarty->register_function(‘list’,’format_data’); Technical support: http://www.net920.cn http://www. ahthink.com ——Solution——————–Smarty3.* can be used, $Smarty->registerPlugin()
Fatalerror:Calltoundefinedfunctioncurl_init()in, how to solve it – php tutorial
Fatal error: Call to undefined function curl_init() inFatal error: Call to undefined function curl_init() in F:\soft\phproot\index.php on line 9 Used IIS+ php5.2.5 php_curl.dll is already in ext in the PHP installation directory, libeay32.dll and ssleay32.dll are already in the PHP installation directory. extension=php_curl.dll has been turned on Solve!!!!!!!!!!!! — —-Solution——————–extension_dir = “D:/php/ext”
PHP intercepts strings, how to solve it – PHP tutorial
PHP intercepts string/book/shopping/%E9%95%BF%E8%A3%99How does PHP intercept the characters before book//%E9%95%BF%E8%A3%99 String ——Solution——————– PHP code $ar=preg_split(‘/[\/]/’,’/book/shopping/%E9%95%BF%E8%A3%99′, -1,PREG_SPLIT_NO_EMPTY);echo $ar[1];