前提天面试的时候,有个技术告诉我,C#的效率要比PHP的高,C#是多线程的,PHP是单线程,我想问一下C#的多线程是怎么体现的?PHP的单线程是怎么体现的?本人应届毕业生,对于基础的东西,不太感兴趣,现在正在恶补...
回复内容:
不管是开发效率还是运行效率,动态类型的先天弱势是无法弥补的。当然如果你仅仅需要hello world... 面试的也是个棒槌…运行效率上说带JIT的编译型语言自然好过动态语言。 谢邀,谢抬爱。




追加一句:
C#和PHP使用场景的不一样,怎么比?比什么比??
你这个渣渣扎古还敢跟我的高达比? “C#的效率要比PHP的高” 这么不严谨的技术人员,还是不要去了,对于你以后的学习和成长绝对是个阻碍。
其实深刻一点的理解,你就会发现,其实C#和PHP根本不能做对比,因为不是同一个物种。不能因为大家都能吃喝拉撒就去比较什么。相比PHP的话用基于C# 实现的http://ASP.NET比较合适。当然如果单独从线程单场方面来比较的话就
PHP没有多线程,是因为你无法在PHP里面去开启一个线程去执行其他任务。所以,多个请求的时候,是交给服务器去处理的。服务器会针对每个用户建立一个php脚本处理进程。所以PHP一般只用在Web开发上面。
C#可以做很多事情,是PHP所无法做到的。C#既可以做Web开发也可以做基于服务器客户端方面的开发。所以多线程处理对C#来说的是多么的重要。你可以写个多线程爬虫软件放在服务器上跑。C#可以做游戏开发,游戏里面大量运用到了多线程处理,等等。再比如C#的web开发,比如用户发起一个不需要返回数据的请求,后台处理又比较耗时,怎么办?开启一个线程,慢慢处理。 1,语言那么多,都是倔强特定问题的。
2,多线程,写得烂,一样效率低。
3,既然在对比php,那项目多半侧重web的。
4,侧重web的,少不了要跟数据库打交道。
5,数据库搞不好,都是翔。
6,时间,开发周期。实战中非常关注的。 “C#效率比PHP高”,是指运行效率高?多线程就比单线程高?那么golang这种纤程是不是又比C#高?node.js这种单线程怎么活?php发展到版本7已经非常快了,可以比下一堆脚本语言,至于C#,更应该和Rust、GO、Swift、Java去比效率 不是单线程多线程问题
是解析型和编译型的问题 带干不干写过大概7年C#,8年PHP。
就语言层面,开发效率PHP更高,因为不用考虑处理类型转换,C#把每种类型都分的很清,相互转换要花很多时间,甚至应用设计模式,PHP基本上学好数组走天下,当然现在也推崇面向对象。
就执行层面,C#使用MSIL作为中间语言,执行时动态编译成native code,PHP使用源代码,执行时动态编译,但是Opcode是可以缓存的。
然后说题主多线程层面,C#虽然内置了多线程的语法糖,但是实际上仍然是需要库(好像是System.Threading)来支持的。当然运行时还是靠Windows系统切换时间片来支持的。PHP默认不提供多线程支持,但是有pThread扩展,同样可以支持多线程。
================================
上面说的都是废话,以下是重点:
“PHP是世界上最好的语言” 他们的效率问题不做评价,但是多线程,单线程跟效率有麻子关系?

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools
