Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String handling in PHP

Tags:

string

php

Can anyone please explain me how string handling is done in PHP. Is it the same as that of done with Java or any other way round. Is there anything like java's StringBuffer class in PHP which will improve the performance of my code while handlling strings.

Please shed light on this.

like image 425
Rahul Shelke Avatar asked Oct 12 '22 05:10

Rahul Shelke


2 Answers

Strings are mutable in php. The only reason something like a StringBuilder is necessary in Java is because Strings are immutable. You can use the concatenation operator (.) all you want.

like image 176
ryeguy Avatar answered Oct 18 '22 09:10

ryeguy


Strings are handled in PHP without much fuss or need for additional libraries (unless you want to start using stuff like UTF-8 encoding).

Native PHP strings are mutable just like the StringBuffer class.

The manual is a good place to start.

like image 24
trickwallett Avatar answered Oct 18 '22 09:10

trickwallett