<?php
$b=('some data from db')
class one{
public $a=$b;
}
i want to initialize the $a with a variable outside the class, but it is not working.
Please how can do this.
Thanks in advace
kingwash 0 Newbie Poster
Recommended Answers
Jump to PostThis depends entirely on what you're trying to do. You should aim to give your class variables (or properties) the lowest visibility possible (i.e. private, protected, public, in that order), but of course it depends if you're going to access those variables directly from outside the class. You could access …
All 3 Replies
cereal 1,524 Nearly a Senior Poster Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

diafol
matrixdevuk commented: Good example. +4
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.