Questions tagged as 'classes'

2
answers

Create product classes and photos and initialize

I have a class Produto and within that class I have a class Categoria and a Class Foto . 1 Product may only have 1 category, but may have multiple Photos. The problem is with the photos. I did so: public class P...
asked by 15.01.2016 / 13:38
2
answers

How to pass an attribute of the child class through the constructor to the parent class

I have 3 classes Mother class: Animal Daughter Classes: Dog and Cat I want to write the name attribute only when one of the objects is instantiated Gato or Cachorro . In the parent class I have the Name attribute that ca...
asked by 28.09.2018 / 19:58
4
answers

Private or protected class in PHP

Is it possible to create a private or protected class in PHP in order to allow access to its variables and functions only to other specific classes? Application: I have a class where I create a connection to the database and wanted to allow...
asked by 22.03.2018 / 20:59
2
answers

Call method by class or instance?

What would be the most correct way to call a method from another class? It is more correct to create the object: private MinhaClasse minhaclasse; minhaclasse = new MinhaClasse(); Then call a method: minhaclasse.meumetodo(); Or just...
asked by 31.03.2018 / 00:39
2
answers

How to edit a Partial Class?

I took a project from a client and it has a class that is partial. When I click to go in the reference opens the file, but in the project I do not find the file, and has the following text in the class file: //---------------------------------...
asked by 30.07.2015 / 22:46
2
answers

Use / change property of an extended class and print by instance

Example scenario Root folder ClassA.php ClasseB.php index.php File: classeA.php class ClasseA { public $retorno = null; public $error = "Erro desconhecido"; function __construct { $this -> fun...
asked by 05.12.2018 / 13:31
1
answer

Where should I instantiate objects?

In OOP there is a certain amount of theory and good practice in writing classes and interfaces. They are inside folders with consecrated nomenclatures. The class name must be identical to the file name. The class must be preceded by the pa...
asked by 31.07.2018 / 07:14
2
answers

PHP builders [closed]

Can not create 2 constructors for a class. How do I instantiate a class and use its functions without having to create a new object? In C #, for example, I use an empty constructor and I can still use one with parameters.     
asked by 14.06.2018 / 19:25
1
answer

How to use a variable within another method of the same class?

How can I use the define_title () method of the $extension variable inside the file_verify >? class Title extends Imoveis { public function file_verify($file) { $file = explode("/", $file); $file...
asked by 27.12.2015 / 17:36
1
answer

How many classes can I put in the same code?

How many "classes" can I add to my code? Let's say I have the following existing command block: namespace _06_ByteBank { public class Cliente { private string _cpf; public string Nome { get; set; } public string CPF...
asked by 07.12.2018 / 15:28