Article View: pl.comp.lang.php
Article #231642Re: public_html
From: Lemat
Date: Mon, 27 Mar 2017 16:58
Date: Mon, 27 Mar 2017 16:58
41 lines
1925 bytes
1925 bytes
W dniu 27.03.2017 o 17:12, Jivanmukta pisze:
> Potrzebuję w programie (framework Codeigniter) mieć dostęp do ścieżki do
> katalogu public_html. W tym celu w pliku config/constants.php zawarłem
> definicję zmiennej globalnej (scieżka getcwd() może się zmieniać w
> trakcie działania programu):
>
> $publicHtmlDir = getcwd();
>
> ale nie podoba mi się to rozwiązanie, bo nie lubię zmiennych globalnych.
> Jak to lepiej zrobić? Może powinienem napisać taką funkcję:
>
> function getPublicHtml() {
> static $publicHtml = getcwd();
> return $publicHtml;
> }
>
> Jak to najlepiej zrobić?
przykład kodu OJP*:
class getPublicHtml {
private $publicHtmlDir;
function __construct() {
$this->publicHtml = getcwd();
}
function get() {
return $this->publicHtml;
}
}
$publicHtmlobj=new getPublicHtml();
$publicHtml=$publicHtmlobj.get();
*O Ja Pierdolę = jedna linia rozwinięta w bezużyteczne, wolne,
zaciemniające obraz milion linii kodu.
--
Pozdrawiam
Lemat
Technical Details
Message-ID:
<58d9448b$0$657$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailReferences:
<obba5f$f5$1@news.icm.edu.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail Subject: Re: public_html Newsgroups: pl.comp.lang.php References: <obba5f$f5$1@news.icm.edu.pl> From: Lemat <#@lemat.priv.pl> Date: Mon, 27 Mar 2017 18:58:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <obba5f$f5$1@news.icm.edu.pl> Lines: 41 Message-ID: <58d9448b$0$657$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 79.189.200.118 X-Trace: 1490633867 unt-rea-b-01.news.neostrada.pl 657 79.189.200.118:53252 X-Complaints-To: abuse@news.neostrada.pl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit