Tips

对最近工作过程中遇到的一些问题,总结与记录一下:
php:
以前不知在哪看到的说eval速度较慢,一直过了这么多年之后,才认真地测试了一下,eval跟include(require)相比速度上没有差别。eval要想执行一个文件,实现跟include(require)同样的效果,需要如下代码,默认文件的内容一开始就是php代码,所以需要先结束一下,然后再打开:

eval("?>" file_get_contents($filename) . "<?php"); 

共享内存与直接磁盘操作的效率对比,对小的文件(<1M),基本没有差别。文件越大,共享内存优势越明显。 css: Gecko浏览器也支持透明,即opacity,如:obj.style.opacity = 0.5; 可惜opera不支持。 js: 比较准确的检测浏览器的方式,利用浏览器的特性:

var isIE    false;
var 
isGecko false;
var 
isOpera false;

if (
window.XMLHttpRequest)
{
    if (
window.opera)
    {
        
isOpera true;
    }
    else
    {
        
isGecko true;
    }
}
else
{
    
isIE true;

原创文章,转载请注明出处

27 Comments »

  1. goog said,

    November 2, 2005 @ 11:41 am

    very good

  2. goog said,

    November 2, 2005 @ 11:41 am

    i like it

  3. Binbin@CCF said,

    November 2, 2005 @ 3:32 pm

    据说eval()的“慢”是因为Zend不对这个进行优化~
    不把程序Zend过是看不出来的~~

  4. ahu said,

    November 3, 2005 @ 12:28 am

    一般不用 能include干吗eval

  5. legend said,

    November 3, 2005 @ 12:49 am

    呵呵,比如说模版存放在数据库中或内存中的时候。

  6. ahu said,

    November 3, 2005 @ 11:17 pm

    ;) 被你说中了

  7. crazysoul said,

    November 9, 2005 @ 3:05 pm

    js:
    比较准确的检测浏览器的方式,利用浏览器的特性:

    这个不够严谨吧,万一其他浏栏版本低的,不支持XMLHttpRequest对像,那也会被认为是IE了?

  8. legend said,

    November 9, 2005 @ 6:04 pm

    我是针对一般情况说得。
    IE5.0以上、Opera8.0以上都支持XMLHTTPRequest,且用Firefpx、Opera的访客一般都会使用新版本。

  9. superspice said,

    December 18, 2005 @ 12:11 pm

    疯狂啊。在有php加速模块时,你用eval就慢得很多了哦。
    况且,php5中的实例已经可以共享内存了。

  10. lzlhero said,

    February 9, 2006 @ 9:27 am

    现在可能有了些变化,因为在 ie 7.0 中,现在同样提供了一个 window.XMLHttpRequest 对象,所以这种判断对 ie 来说,会不准确。我还是比较倾向于使用 userAgent 或 appName 来判断。

  11. deadlm888 said,

    April 6, 2006 @ 6:22 pm

    eval在zend引擎上使用的每一次都会在运行之前进行一次初始化的模式转换,相当于重新请求一个新页面

  12. cialis said,

    December 6, 2006 @ 3:19 pm

    http://smurl.name/p9x2 cialis cialis
    cialis
    generic cialis
    buy cialis
    cialis forum
    cheapest cialis
    cheap cialis
    viagra cialis levitra

  13. free ringtones said,

    December 20, 2006 @ 6:47 pm

    free ringtones
    http://www.ForumAnbieter.de/board/index.php?nxu=89658542nx1417
    free ringtones

  14. 同声翻译公司 said,

    August 29, 2007 @ 7:11 pm

    从事各专业翻译服务,包括笔译、口译、同声传译和同声传译设备租赁等。我们需要招聘兼职翻译、同传译员和外籍英文校对人员
    希望有机会合作.
    郭先生

    北京华译网翻译公司北京海淀区太阳园17号楼405室(北三环西路大钟寺东侧)邮编:100098
    E-mail:bjctn@vip.sina.com
    电话:010-82115891 82115892 传真010-82130386

  15. UnsedlesUneft said,

    January 28, 2008 @ 12:41 pm

    http://www.lavaink.com/forum/viewtopic.php?p=3444

  16. seo said,

    January 19, 2014 @ 7:53 pm

    I really like it when people get together and share opinions.
    Great blog, stick with it!

  17. Princess said,

    January 23, 2014 @ 7:56 am

    I will right away grab your rss feed as I can not to
    find your email subscription hyperlink or newsletter service.

    Do you’ve any? Please let me recognize in order that I may subscribe.
    Thanks.

  18. Jc said,

    February 3, 2014 @ 2:41 pm

    I every time used to read article in news papers but now as I
    am a user of internet therefore from now I am using net for articles, thanks to web.

  19. Basil said,

    February 14, 2014 @ 4:47 am

    This website was… how do I say it? Relevant!!
    Finally I’ve found something which helped me. Kudos!

  20. www.boyamaoyunlari.me said,

    February 26, 2014 @ 6:10 am

    Asking questions are actually good thing if you are
    not understanding anything totally, except this post offers fastidious understanding yet.

  21. http://www.весь-тихвин.xn--p1ai/board/obyavlenie/prodam/massage-tips-tricks-and-pointers-you-can-use said,

    February 26, 2014 @ 6:13 am

    Very good information. Lucky me I found your blog by accident (stumbleupon).
    I have saved it for later!

  22. best diet said,

    February 28, 2014 @ 4:51 pm

    Amazing issues here. I am very glad to peer your article.
    Thanks a lot and I’m looking ahead to touch you.
    Will you please drop me a mail?

  23. http://shop.oesterreich-privat.com/ said,

    March 2, 2014 @ 10:50 am

    Please let me know if you’re looking for a article writer for your
    site. You have some really great posts and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some
    material for your blog in exchange for a link back to mine.
    Please shoot me an email if interested. Cheers!

  24. http://www.ltf3.org/users.php?mode=profile&uid=44814 said,

    March 3, 2014 @ 8:18 pm

    This is really interesting, You’re a very skilled blogger.
    I have joined your rss feed and look forward to
    seeking more of your great post. Also, I have shared your website in my social networks!

  25. waist to hip ratio said,

    March 8, 2014 @ 9:00 am

    Quality posts is the main to invite the users to
    visit the website, that’s what this web page is providing.

  26. 1 said,

    March 12, 2014 @ 10:34 am

    Great post. I was checking constantly this blog and I’m impressed!
    Very helpful information specifically the last part :
    ) I care for such information a lot. I was seeking this
    particular information for a long time. Thank you and good luck.

  27. Randi said,

    March 15, 2014 @ 7:21 am

    Can I just say what a comfort to discover somebody that really understands
    what they are talking about online. You certainly realize
    how to bring an issue to light and make it important.
    More and more people must read this and understand this side of your story.
    I can’t believe you are not more popular since you surely have the gift.

RSS feed for comments on this post

Leave a Comment