PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 22, 2022

[FIXED] Which concepts of OOP are not available in PHP

 July 22, 2022     oop, php, php-5.4     No comments   

Issue

I searched this alot on net, but unable to find the answer that many people ask in the interview questions or in general question when they talk about PHP..

Which concepts of OOP are not available in PHP?

I have heard and read this many many time that PHP is not a completely OOP language, but when i google it, i am unable to find that which concepts of OOP are not available in PHP.


Solution

There is no built-in method for type casting of user defined objects in PHP (despite of having some workarounds).

<?php

class Book
{
    public $title;
    public $isbn;
}

class BookShelf
{
    public static function create($booklist)
    {
        echo "Here are your books!";
    }
}

$bookList = new Book;
BookShelf::create($bookList); // output "Here are your books!"

$bookList = new stdClass();
BookShelf::create((Book)$bookList); // output a parse error of undefined variable $bookList


Answered By - al'ein
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing