Skip to content

Migration Guide

Dmitriy Zayceff edited this page Apr 29, 2015 · 13 revisions

JPHP has the zend legacy extension, but you may have problems when you work with it. We recomend you to do not use this extension and try to use better approach from the JPHP Standard Library.

String Functions

The JPHP has own util class for working with strings php\lib\String, for example:

use php\lib\String;

$result = String::sub($string, 1);

// instead of ...

$result = substr($string, 1);

This class contains many useful methods:

  • strpos -> String::pos
  • stripos -> String::posIgnoreCase
  • strrpos -> String::lastPos
  • strripos -> String::lastPosIgnoreCase
  • strcmp -> String::compare
  • strcasecmp -> String::compareIgnoreCase, String::equalsIgnoreCase
  • ??? -> String::startsWith
  • ??? -> String::endsWith
  • strtolower -> String::lower
  • strtoupper -> String::upper
  • strlen -> String::length
  • str_replace -> String:replace // unable to work with arrays
  • str_repeat -> String::repeat
  • trim -> String::trim
  • rtrim -> String::trimRight
  • ltrim -> String::trimLeft
  • strrev -> String::reverse
  • str_shuffle -> String::shuffle, String::random
  • explode -> String::split
  • implode -> String::join
  • iconv -> String::encode, String::decode
  • ??? -> String::isLower
  • ??? -> String::isUpper

Clone this wiki locally