Convert An Object To Associative Array In Php

Seeing other languages like Java or C++ String is an Object.But in PHP is it the same thing ? Should I write string or String?I know it may be a strange question but I can"t find the answer even on

Thank you very much.

Bạn đang xem: Convert an object to associative array in php


A string is not an Object in PHP. You don"t have sầu khổng lồ cast the types of variables in PHP.. Seeà


A String is not a Object in PHPhường by Default and casting is not required but it can be introduced if you want using scalar_objects

class StringHandler public function length() return strlen($this); register_primitive_type_handler("string", "StringHandler");So you can easily have sầu



String is not an object in PHP, it"s a primitive type. The information is on

Lowercase string is correct for the few uses you might have sầu.


You can find pretty much everything related lớn types here:


String và object are two different things. But if you wanted lớn run your own checks:

if (is_object($var)) eđến "Var is an object"; elseif (is_string($var)) emang đến "var is a String"; else echo "var is neither an object or string";
Everyting can be achieved via the built-in functions of PHPhường, so you can vì all that you can with String objects.

Xem thêm: Bí Quyết Giao Tiếp Giỏi - 14 Thói Quen Giúp Bạn Có Cách Giao Tiếp Tốt

Thanks for contributing an answer to Staông xã Overflow!

Please be sure lớn answer the question. Provide details and cốt truyện your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; bachồng them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to lớn our terms of service, privacy policy and cookie policy

site thiết kế / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.3.19.38843