Current location - Recipe Complete Network - Complete cookbook - PHP intercepts string code like this:

Write one:

Class personage

{

public $ str

Functional personnel (str)

{

$ this-& gt; str = $ str

}

Common fun

PHP intercepts string code like this:

Write one:

Class personage

{

public $ str

Functional personnel (str)

{

$ this-& gt; str = $ str

}

Common fun

PHP intercepts string code like this:

Write one:

Class personage

{

public $ str

Functional personnel (str)

{

$ this-& gt; str = $ str

}

Common function name ($len)

{

$ n = substr($ this-& gt; str,0,$ len);

echo $ n;

Returns $ n;;

}

}

$ product = new person (iconv ("UTF-8 ","GBK ","A Duo Guliqi Haha Lavasha "));

$ product-& gt; Name (8); //Output "A Duo Guli" after execution (each Chinese character occupies two bytes).