php-general Digest 28 Apr 2001 10:54:53 -0000 Issue 654
Topics (messages 50704 through 50746):
Re: online site builder
50704 by: Godd
Strange Question - Please Read This
50705 by: Chris Anderson
50709 by: Zak Greant
Why is this?
50706 by: Manesh
Re: line break part2
50707 by: Dddogbruce \(.home.com\)
[NEWBIE] :P
50708 by: Dddogbruce \(.home.com\)
50726 by: PHPBeginner.com
include whole directories?
50710 by: andrew
50714 by: Erica Douglass
undefined symbol: SSL_CTX_set_rsa_callback
50711 by: j2n tech
50732 by: Dean Hall
Re: PHP Book?
50712 by: Chris Anderson
50723 by: Martin Skj�ldebrand
50742 by: Christian Reiniger
Re: Can I install Lihnux on My Windows 95 machine ?
50713 by: Valter Santos
Find and Replace script: Content Stripper; recursive subdirectories; ereg_replace,
preg_replace
50715 by: Erica Douglass
count() problem :D
50716 by: Chris Schneck
50724 by: Chris Adams
50729 by: Joe Sheble \(Wizaerd\)
Database
50717 by: Manesh
phpwebsite
50718 by: Manesh
50719 by: Brian Clark
tester needed for phpMyMultiBackup
50720 by: idban secandri
Where is php.ini located by default?
50721 by: Martin Skj�ldebrand
50722 by: idban secandri
50725 by: PHPBeginner.com
50727 by: Chris Fry
50728 by: PHPBeginner.com
50730 by: Erica Douglass
50731 by: Martin Skj�ldebrand
50735 by: idban secandri
50740 by: Steven Haryanto
50743 by: yanto
dynamically adding rows to same form.
50733 by: Rahul Bhide
Re: columns
50734 by: Adrian D'Costa
bd access
50736 by: Sandro Spadaro
run du command uder php
50737 by: Mark Lo \(3\)
50738 by: idban secandri
can someone debug this vote.php script for me?
50739 by: Joe Truong
Please review our coding standards
50741 by: Steven Haryanto
Newbie question - adding vars
50744 by: Jamie Saunders
50745 by: Alexander Wagner
Links
50746 by: Ben Quinn
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
Well I am working on just such a project now. Mine is a bit more complex
than just the simple page. I am working on actually building a site that
allows you to build a dynamic site. So you will be able to make tables in a
database and use these tables to build query and tables and all sorts of
things that will create the site. The hard part for me right now is adding
all the tags so that they can format the page and insert images and all that
stuff. but it is coming along. I started to build this because I have not
found any tool out there that does that as yet.
""kaab kaoutar"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi all!
> Is using php the right technology with which i can create an online site
> builder! i mean i want to enable users to create their own sites
> in few minutes by choosing one model of the ones proposed, the colors, etc
u
> know like these site builders sites?
> if not do u thnik there are specific tools i may use to fullfill these? or
i
> have to do it from scrach using jsp or java ?
> Thanks a lot
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
Does anyone know how to place code into every file accessed on my server? Kindof like
how geocities and countless other hosts manage to add their banners?
Chris Anderson aka "Null"
--------------------------------------------
PHP Developer / Nulltech
PHP-GTK Tester / gtk.php.net
STA Administrator / www.stronger.org
DOD Co-Owner / www.dayofdefeat.com
Set the auto_append_file or auto_prepend_file in the php.ini file.
See http://www.php.net/manual/en/configuration.php for more details
--zak
----- Original Message -----
From: "Chris Anderson" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 11:50 AM
Subject: [PHP] Strange Question - Please Read This
Does anyone know how to place code into every file accessed on my server?
Kindof like how geocities and countless other hosts manage to add their
banners?
Chris Anderson aka "Null"
--------------------------------------------
PHP Developer / Nulltech
PHP-GTK Tester / gtk.php.net
STA Administrator / www.stronger.org
DOD Co-Owner / www.dayofdefeat.com
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
$string = nl2br($string)
This will change a new line into <br>; but make sure HTMLspecialchars aren't
in the same part.
Hi.
I'm writing a new script, but I need some help.. I won't post here
because it's just too much. I'm looking for someone who is dedicated
and patient in helping a 13 year old with SQL and connecting/recieving,
inserting and updating databases. I have ideas, I have some basic
knowledge of PHP but I need someone who can help answer questions,
patiently.
If you wouldn't mind helping (I realise this may sound stupid) please
message me. 51599351 on ICQ.
Thanks,
Owen
Hi Owen,
newbies are always welcome here (as long as you mention it).
See, we developers, are often too bored answering the complicated questions.
But if you ask something like:
"what is the syntax for update" you'll get dozens of replies.
don't try on mySQL lists, I noticed that they are kind of snobby, simple
questions are not too respected over there.
This is definitely a right place for you.
also try this sites:
PHPBeginner.com (mine BTW)
NewbieNetwork.net
search google,
check list archives ( http://marc.theaimsgroup.com/?l=php-general )
got a question : juts ask,
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com
-----Original Message-----
From: Dddogbruce (@home.com) [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 28, 2001 8:39 AM
To: [EMAIL PROTECTED]
Subject: [PHP] [NEWBIE] :P
Hi.
I'm writing a new script, but I need some help.. I won't post here
because it's just too much. I'm looking for someone who is dedicated
and patient in helping a 13 year old with SQL and connecting/recieving,
inserting and updating databases. I have ideas, I have some basic
knowledge of PHP but I need someone who can help answer questions,
patiently.
If you wouldn't mind helping (I realise this may sound stupid) please
message me. 51599351 on ICQ.
Thanks,
Owen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
Is there any way to include whole directories?
I have my function declarations in many small, easily maintainable
files, but it's a pain to include/require them all individually...I
would like to just split them into directories by common purpose, e.g
functions/auth
functions/content
functions/modules
and then include a directory at once - any ideas?
cheers!
andrew
Sure. Use an array, as suggested in the example on the include manual page,
but put all files in a specific directory in that array. To do that, use
code like the following:
# load files into array
# assign $directory to your variable, or replace $directory in the below
line with the directory you want.
$handle=opendir($directory);
while ($file = readdir($handle)) { # read all files in dir
if ($file != ".." && $file != ".") {
$files_to_include[count($files_to_include)] = $file; # cram them files
into array ;)
};
};
#clean up and sort
closedir($handle);
if (is_array($files_to_include)) {
while (list ($key, $val) = each ($files_to_include)) {
include $files[$i];
};
};
I modified some previous code to work for what you want, so my apologies if
there are missing curly braces or the like.
Hope this helps,
Erica
"andrew" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> Is there any way to include whole directories?
> I have my function declarations in many small, easily maintainable
> files, but it's a pain to include/require them all individually...I
> would like to just split them into directories by common purpose, e.g
>
> functions/auth
> functions/content
> functions/modules
>
> and then include a directory at once - any ideas?
>
> cheers!
> andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
After compiling php404pl1 and Apache 1.3.12:
[root@ conf]# ../bin/apachectl restart
../bin/apachectl restart: httpd not running, trying to start
Syntax error on line 207 of /var/www/conf/httpd.conf:
Cannot load /var/www/libexec/libphp4.so into server:
/var/www/libexec/libphp4.so: undefined symbol: SSL_CTX_set_tmp_rsa_callback
../bin/apachectl restart: httpd could not be started
[root@ conf]#
Anyone have any ideas?
thanks..
-j2n
""j2n tech"" <[EMAIL PROTECTED]> wrote in message
9cd2bn$55m$[EMAIL PROTECTED]">news:9cd2bn$55m$[EMAIL PROTECTED]...
> After compiling php404pl1 and Apache 1.3.12:
>
> [root@ conf]# ../bin/apachectl restart
> ../bin/apachectl restart: httpd not running, trying to start
> Syntax error on line 207 of /var/www/conf/httpd.conf:
> Cannot load /var/www/libexec/libphp4.so into server:
> /var/www/libexec/libphp4.so: undefined symbol:
SSL_CTX_set_tmp_rsa_callback
> ../bin/apachectl restart: httpd could not be started
> [root@ conf]#
>
> Anyone have any ideas?
What configure options did you use for PHP and Apache? Did you install any
other modules for Apache?
Dean.
A good book for a beginner is "The PHP 4 Bible"
Chris Anderson aka "Null"
--------------------------------------------
PHP Developer / Nulltech
PHP-GTK Tester / gtk.php.net
STA Administrator / www.stronger.org
DOD Co-Owner / www.dayofdefeat.com
----- Original Message -----
From: "Alex Piaz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 7:14 PM
Subject: Re: SV: [PHP] PHP Book?
> Hi All!
>
> One of the best books on PHP that I ever read is "Web Application
> Development with PHP 4.0" from New Riders.
>
> It is an advanced book, not recomend it for beginners, but the
> medium/advanced skill programmer will love it.
>
>
> THat's my 10 reais (brazillian money):-)
>
> []'s
>
>
>
> Alex Piaz
> Webmaster
> Global Map Internet Marketing
> www.globalmap.com
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> "Those who know what's best for us -
> Must rise and save us from ourselves"
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
[EMAIL PROTECTED] wrote:
> On Fri, Apr 27, 2001 at 08:06:54PM +0200, Christian Reiniger wrote:
>> On Friday 27 April 2001 15:15, Johan Holst Nielsen wrote:
>> > > Hey everyone...
>> > >
>> > > I've been programming in perl for about 3 years now, i have installed
>> > > php and have been working on it for about three weeks. I started by
>>
>> > Try "Core PHP Programmning", it's have a lot of good stuff!
>>
>> That book is definitely the wrong choice for someone with 3 years perl
>> experience (perhaps unless there's a second edition). The copy I
>> unfortunately bought is built somehow like that:
>
> What books are you reading?
>
>> 5 pages useful intro
>> 45 pages explaining basic language contructs [1]
>> 4 pages explaining classes
>> 11 pages giving a (small) overview of using print(), getting data from
>> forms, file upoads, env-vars, cookies, include/require and file IO
>> 340 pages function references (copied from the manual) [2]
>
> That is wrong. Leon havent copied 340 pages from the manual. I should know
> this myself because I have finished the translation into German.
Well, for the first edition of this book I found it extremely boring. Don't
know why really. The whole thing felt pretty old - but it isn't. Hopefully
the second ed. is much better. (I know many people like PHP Core).
Anyway, PHP Developers Cookbook (Sterling Hughes) from SAMS is very nice.
Gives lot's of examples of everyday stuff you'd like to do.
M.
On Saturday 28 April 2001 00:36, [EMAIL PROTECTED] wrote:
> > > > IO 340 pages function references (copied from the manual) [2]
> > >
> > > That is wrong. Leon havent copied 340 pages from the manual. I
> > > should know this myself because I have finished the translation
> > > into German.
> >
> > Ok, I guess you're right. sorry. What I wanted to express is that the
> > same information is in the online manual.
>
> That is also wrong.
<looking>
Ok, I again stand corrected. The reference in the book contains
additional examples and explanatory texts. Sorry Leon, sorry Egon.
So here's a rephrased version of what I wanted to express with my
original mail:
The book is targeted at people completely new to PHP and relatively new
to programming as such, and thus it is IMO next to useless for someone
with "3 years Perl experience" (which is what this thread originally was
about). Again, I can only speak about the first edition - if you say the
second Ed has changed in this regard that's great.
> > > Please read books more carefully and don't pester this mailing list
> > > with your nonsense comments. I mean that book with a foreword by
> > > Andi Gutmans.
> >
> > Well, you just said "Core PHP Programming" and I described that book.
> > But you're right in that I know nothing about the second edition.
>
> I haven't start this thread. So be carefull. I have Leons second
> edition and you can buy another book at Markt+Technik. The PHP manual
> is for free use. Use that if you are not comfortable with Leons book.
>
> It is not very good to judge some books on this list. I know some
> authors who contribute to the PHP manual and write own books.
Well, someone recommended that book, and I tried pointing out that IMO
that book is the wrong choice for that particular person.
I apologize for putting down the book as something generally bad (that
wasn't intended), but I don't apologize for having an opinion and telling
others about it.
This list is a *good* place for book reviews, because (1) reviews help
(future) readers to choose the right book for them and (2) because bad
reviews (such as mine) can be easily corrected (as you did) here.
--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)
Very funny, Scotty! Now beam up my clothes...
Of course you can run both win95 and linux in the
same machine!
You can install linux on your F: drive and run a
OS loader such Lilo at startup (lilo is installed
with your linux distribution)!
Go ahead... install Linux!!!
BTW, there is a Apache version for Windows!
............................................
Valter Santos
WEB/WAP Consultant
Email : [EMAIL PROTECTED]
Mobile: +351 93 9650075
WeDo Consulting - http://www.wedo.pt
............................................
> -----Original Message-----
> From: Manisha [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 25, 2001 2:10 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Can I install Lihnux on My Windows 95 machine ?
>
>
> Hi all,
>
> I am having my own personal computer running on windows 95. I
> have C / D /
> E / F / G drives with FAT 32 file system with lot of information on it. I
> can format one drive out of these.
>
> Can I install Linux on it ? (i.e. format F:\ and load Linux). Later on I
> want to load Apache also on it.
>
> Is it feasible ? Any information about this on web ? If I format
> one drive
> and load Linux whether other drive info will get affected ?
>
> manisha
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
I have created a content stripper file that I am releasing to this newsgroup
as freeware.
The file takes a .html file that looks like this:
_________________
HEADER
_________________
CONTENT
_________________
FOOTER
_________________
and strips out the header and footer according to certain delimiters in the
.html file. Although it was made for a very specific purpose, it can be
modified to do a number of things. It recurses subdirectories, so it can be
used as a general find/replace file with an HTML interface. It is freeware
and can be freely modified. I'd appreciate it if you let me know where you
are using this file, however.
Please send any suggestions regarding this file to [EMAIL PROTECTED]
Thanks to all who helped me write the regular expressions -- I sincerely
appreciate your help.
------------------------------
-- erica douglass --
-- [EMAIL PROTECTED] --
------------------------------
<?php
#content_update.php
#erica douglass, 4/2001.
#suggestions are welcome... please mail them to [EMAIL PROTECTED]
if ($action == "strip") {
strip_files($directory);
find_subdirs($directory);
}
else {
print_html();
};
function print_html() {
?>
<html>
<head>
<title>Content Stripper</title>
<body>
<p><font face="Verdana, Arial, Helvetica, sans-serif">
Make sure all directories you are about to strip have write access for your
web server user (usually user "httpd".) To do this through the command line,
get root access and type the following:<br>
<br>chown -R httpd <i>directory</i></b>
<br>where <i>directory</i> is the directory where your HTML files are
located. The -R option means "recursive",
which changes all subdirectories of the directory you specify. Don't use -R
unless you include the full path
of the files, e.g. <i>chown -R /home/sites/home/web/test .</i>
<br><br>Enter the directory from which you would like to strip files
(example: /home/sites/home/web/test):<br>
</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="+1"><b>Security
Alert!</b> If you change your files
to be owned by your web server user, anyone with malicious intent can harm
them from the web. Therefore, it is
suggested that you immediately <b>chown -R root</b> (or your username)
<i><b>directory</b></i> from a command prompt after you run this script.
Although
the script itself cannot be hacked, we still strongly recommend making the
above change.</font></p>
<form action="<?php print $PHP_SELF; ?>" method="post">
<input type="text" size="30" name="directory">
<input type="hidden" name="action" value="strip">
<input type="submit" name="submit" value="Strip 'em!">
</form>
</body>
</html>
<?php
};
function strip_files($directory) {
$handle=opendir($directory); # open dir
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"+1\">Reading directory <b>$directory</b>...<br>";
while (false!==($file = readdir($handle))) { # read all files in dir
if (eregi(".*\.html$", $file)) { # as long as it ends with .html (case
insensitive)
print "Now stripping header and footer from
<i>$directory/$file</i>...<br>";
$file = $directory . "/" . $file; #make sure file has the proper directory
appended to it
# get contents of a file into a string
$fd = fopen ($file, "r");
$contents = fread ($fd, filesize ($file));
fclose ($fd);
# replace header gif (any img tag with src=images/headers)
$contents = preg_replace ("/<IMG.+SRC=\"images\/headers.*>/", "",
$contents);
$contents = preg_replace ("/<IMG.+SRC=\"\/forte\/images\/headers.*>/", "",
$contents);
# now, find occurrence of <!-- MAIN CONTENT --> and delete everything
before it.
$contents = ereg_replace (".*<\!-- MAIN CONTENT -->", "", $contents);
# replace all occurrences of <!-- ============ -->
$contents = ereg_replace ("<\!-- ============ -->", "", $contents);
# replace everything after <!-- END OF MAIN CONTENT -->
$contents = ereg_replace ("<\!-- END OF MAIN CONTENT -->.*", "",
$contents);
# rename old file to $file.old
rename ("$file", "${file}.old");
# write new file ($contents) to $file
$fp = fopen (strtolower($file), "a+");
fwrite ($fp, $contents);
fclose ($fp);
# print congratulations message
print "<b>$file</b> has been stripped. Your original file is called
<i>${file}.old.</i><br><br>";
};
}
print "</font>";
closedir($handle); # close file
}; # end function strip_files
function find_subdirs($directory) {
# load subdirectories into array
$handle=opendir($directory);
while ($file = readdir($handle)) { # read all files in dir
if ($file != ".." && $file != ".") {
$file = $directory . "/" . $file; # ensure that is_dir picks the
directories up properly
if (is_dir($file)) {
$subdirs[count($subdirs)] = $file;
};
};
};
#clean up and sort
closedir($handle);
if (is_array($subdirs)) {
sort($subdirs);
while (list ($key, $val) = each ($subdirs)) {
strip_files($val);
find_subdirs($val);
}
};
}; # end function find_subdirs
hey all, this is my first message to this group, im gonna print it out :)
anywho, im having problems getting data out of the count() function i've
implemented, could anyone lend a hand?
$query = "select count(fld_gender) from tbl_survey";
how exactly is it that you output data retrieved from a count()
implementation?
On 27 Apr 2001 19:50:04 -0700, Chris Schneck <[EMAIL PROTECTED]> wrote:
>anywho, im having problems getting data out of the count() function i've
>implemented, could anyone lend a hand?
>
> $query = "select count(fld_gender) from tbl_survey";
>
>how exactly is it that you output data retrieved from a count()
>implementation?
The same way you retrieve data from any other query - SQL functions like
count() or sum() return data in the same fashion as normal, non-computed data.
As an example:
$foo = mysql_query("select count(*) from table");
echo "Number of records in table: " . mysql_result($foo, 0);
Alias the count()
$query = "select count(fld_gender) s sumField from tbl_survey";
$result = mysql_query( $query, $dbConnection );
$aRow = mysql_fetch_array( $result );
print( $aRow["sumField"] );
Joseph E. Sheble
a.k.a. Wizaerd
Wizaerd's Realm
Canvas, 3D, Graphics,
ColdFusion, PHP, and mySQL
http://www.wizaerd.com
=================================
> -----Original Message-----
> From: Chris Adams [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 27, 2001 9:31 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] count() problem :D
>
>
> On 27 Apr 2001 19:50:04 -0700, Chris Schneck
> <[EMAIL PROTECTED]> wrote:
> >anywho, im having problems getting data out of the count() function i've
> >implemented, could anyone lend a hand?
> >
> > $query = "select count(fld_gender) from tbl_survey";
> >
> >how exactly is it that you output data retrieved from a count()
> >implementation?
>
> The same way you retrieve data from any other query - SQL functions like
> count() or sum() return data in the same fashion as normal,
> non-computed data.
>
> As an example:
> $foo = mysql_query("select count(*) from table");
> echo "Number of records in table: " . mysql_result($foo, 0);
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
How do i make table, just a simple one called sympoll_auth
I got this from a site, and how do i set up the mail fetures?
Hi Manesh,
@ 12:07:05 AM on 4/28/2001, Manesh wrote:
> I got this from a site, and how do i set up the mail fetures?
Got what from a site? Which mail features?
-Brian
--
PGP is spoken here: 0xE4D0C7C8
Please, DO NOT carbon copy me on list replies.
Just releasing phpMyMultiBackup; a php scripts that can backup MySQL
database(s) from many server(s)
i need more tester, scripts can d/l from
http://phpklik.dhs.org/phpmymultibackup/
I've built php from a tarball. Now I need to specify a special include path
in the php.ini file. But I can't find it. There is a php.in-dist in the
build catalog but I can't find a production php.ini anywhere.
The docs says that it should be in the install catalogue (which is where?,
/usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
sample file and putting it in either place but my app still gives me the
following error:
Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
in FILENAME
Martin S.
On Saturday 28 April 2001 00:37, you wrote:
> I've built php from a tarball. Now I need to specify a special include path
> in the php.ini file. But I can't find it. There is a php.in-dist in the
> build catalog but I can't find a production php.ini anywhere.
> The docs says that it should be in the install catalogue (which is where?,
> /usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
> sample file and putting it in either place but my app still gives me the
> following error:
>
> Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
> in FILENAME
>
> Martin S.
read INSTALL doc, they will told you
/usr/lib/php
is the default configuration... if I am not worng... 'cause I have some
memory leaks recently :-)
have you tried :
# locate php.ini
# locate php.ini-dist
while on windows it should be located in WINNT directory (on NT/2K). It will
ask YOU to move them there during the installation.
Sincerely,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com
-----Original Message-----
From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 28, 2001 1:38 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Where is php.ini located by default?
I've built php from a tarball. Now I need to specify a special include path
in the php.ini file. But I can't find it. There is a php.in-dist in the
build catalog but I can't find a production php.ini anywhere.
The docs says that it should be in the install catalogue (which is where?,
/usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
sample file and putting it in either place but my app still gives me the
following error:
Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
in FILENAME
Martin S.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
It's /usr/local/lib/php.ini
Chris
"PHPBeginner.com" wrote:
> /usr/lib/php
> is the default configuration... if I am not worng... 'cause I have some
> memory leaks recently :-)
>
> have you tried :
> # locate php.ini
> # locate php.ini-dist
>
> while on windows it should be located in WINNT directory (on NT/2K). It will
> ask YOU to move them there during the installation.
>
> Sincerely,
>
> Maxim Maletsky
> Founder, Chief Developer
>
> PHPBeginner.com (Where PHP Begins)
> [EMAIL PROTECTED]
> www.phpbeginner.com
>
> -----Original Message-----
> From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, April 28, 2001 1:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Where is php.ini located by default?
>
> I've built php from a tarball. Now I need to specify a special include path
> in the php.ini file. But I can't find it. There is a php.in-dist in the
> build catalog but I can't find a production php.ini anywhere.
> The docs says that it should be in the install catalogue (which is where?,
> /usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
> sample file and putting it in either place but my app still gives me the
> following error:
>
> Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
> in FILENAME
>
> Martin S.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW 2217
Australia
Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http://www.quillsoft.com.au
You can download our Public CA Certificate from:-
https://ca.secureanywhere.com/htdocs/cacert.crt
**********************************************************************
This information contains confidential information intended only for
the use of the authorised recipient. If you are not an authorised
recipient of this e-mail, please contact Quillsoft Pty Ltd by return
e-mail.
In this case, you should not read, print, re-transmit, store or act
in reliance on this e-mail or any attachments, and should destroy all
copies of them.
This e-mail and any attachments may also contain copyright material
belonging to Quillsoft Pty Ltd.
The views expressed in this e-mail or attachments are the views of
the author and not the views of Quillsoft Pty Ltd.
You should only deal with the material contained in this e-mail if
you are authorised to do so.
This notice should not be removed.
true, true...
m
-----Original Message-----
From: Chris Fry [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 28, 2001 2:23 PM
To: PHPBeginner.com
Cc: Martin Skjoldebrand; [EMAIL PROTECTED]
Subject: Re: [PHP] Where is php.ini located by default?
It's /usr/local/lib/php.ini
Chris
"PHPBeginner.com" wrote:
> /usr/lib/php
> is the default configuration... if I am not worng... 'cause I have some
> memory leaks recently :-)
>
> have you tried :
> # locate php.ini
> # locate php.ini-dist
>
> while on windows it should be located in WINNT directory (on NT/2K). It
will
> ask YOU to move them there during the installation.
>
> Sincerely,
>
> Maxim Maletsky
> Founder, Chief Developer
>
> PHPBeginner.com (Where PHP Begins)
> [EMAIL PROTECTED]
> www.phpbeginner.com
>
> -----Original Message-----
> From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, April 28, 2001 1:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Where is php.ini located by default?
>
> I've built php from a tarball. Now I need to specify a special include
path
> in the php.ini file. But I can't find it. There is a php.in-dist in the
> build catalog but I can't find a production php.ini anywhere.
> The docs says that it should be in the install catalogue (which is where?,
> /usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
> sample file and putting it in either place but my app still gives me the
> following error:
>
> Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
> in FILENAME
>
> Martin S.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW 2217
Australia
Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http://www.quillsoft.com.au
You can download our Public CA Certificate from:-
https://ca.secureanywhere.com/htdocs/cacert.crt
**********************************************************************
This information contains confidential information intended only for
the use of the authorised recipient. If you are not an authorised
recipient of this e-mail, please contact Quillsoft Pty Ltd by return
e-mail.
In this case, you should not read, print, re-transmit, store or act
in reliance on this e-mail or any attachments, and should destroy all
copies of them.
This e-mail and any attachments may also contain copyright material
belonging to Quillsoft Pty Ltd.
The views expressed in this e-mail or attachments are the views of
the author and not the views of Quillsoft Pty Ltd.
You should only deal with the material contained in this e-mail if
you are authorised to do so.
This notice should not be removed.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
If I'm not mistaken, the "locate" command uses a cache which is only updated
every 24 hours or so. You can either recreate locate's cache by reading
locate's man pages, or you can actually search the filesystem by using the
following commands:
cd / (go to the root directory)
find . -name php.ini
The last command actually searches the filesystem at the time the command is
executed, instead of relying on a cached database like the locate command.
Of course, if the file has been on your system for a while and has not
recently changed location, you should probably use locate because the search
will be faster.
Also, another tip: To make sure you know where the configuration file is
going to be, compile PHP with this option:
./configure --with-config-file-path=/etc/httpd (or wherever you would like
to place your file.)
Erica
""PHPBeginner.com"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> /usr/lib/php
> is the default configuration... if I am not worng... 'cause I have some
> memory leaks recently :-)
>
> have you tried :
> # locate php.ini
> # locate php.ini-dist
>
> while on windows it should be located in WINNT directory (on NT/2K). It
will
> ask YOU to move them there during the installation.
>
>
> Sincerely,
>
> Maxim Maletsky
> Founder, Chief Developer
>
> PHPBeginner.com (Where PHP Begins)
> [EMAIL PROTECTED]
> www.phpbeginner.com
>
>
>
>
> -----Original Message-----
> From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, April 28, 2001 1:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Where is php.ini located by default?
>
>
> I've built php from a tarball. Now I need to specify a special include
path
> in the php.ini file. But I can't find it. There is a php.in-dist in the
> build catalog but I can't find a production php.ini anywhere.
> The docs says that it should be in the install catalogue (which is where?,
> /usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
> sample file and putting it in either place but my app still gives me the
> following error:
>
> Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
> in FILENAME
>
> Martin S.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
idban secandri wrote:
> On Saturday 28 April 2001 00:37, you wrote:
>> I've built php from a tarball. Now I need to specify a special include
>> path in the php.ini file. But I can't find it. There is a php.in-dist in
>> the build catalog but I can't find a production php.ini anywhere.
>> The docs says that it should be in the install catalogue (which is
>> where?, /usr/local/lib/php doesn't have one) or the cwd. I've tried
>> editing the sample file and putting it in either place but my app still
>> gives me the following error:
>>
>> Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
>> in FILENAME
>>
>> Martin S.
>
>
> read INSTALL doc, they will told you
>
Found the litte line.
Thanks - too all who replied!
Martin S.
On Saturday 28 April 2001 01:23, you wrote:
> It's /usr/local/lib/php.ini
NEW: Unix install paths changed
Please note that the PHP 4.0.5 release will have a new set of installation
paths for any Unix-like operating systems.
The default php.in path is now "/usr/local/etc" (previously "/usr/local/lib")
PEAR will be placed in "/usr/local/share/php/pear" (previously
"/usr/local/lib/php") shared extensions can be found in"/usr/local/lib/php"
http://www.zend.com/zend/week/week34.php
btw, i found that the configure option:
--with-config-file-path=PATH
is slightly misleading, as "PATH" to usually refers to a file
location. moreoever, php does not report if it fails to read
a php.ini. perhaps the text should be rewritten as:
--with-config-file-path=DIR
Steve
At 4/28/2001 11:37 AM, Martin =?ISO-8859-4?Q?Skj=F6ldebrand?= wrote:
>I've built php from a tarball. Now I need to specify a special include path
>in the php.ini file. But I can't find it. There is a php.in-dist in the
>build catalog but I can't find a production php.ini anywhere.
>The docs says that it should be in the install catalogue (which is where?,
>/usr/local/lib/php doesn't have one) or the cwd. I've tried editing the
>sample file and putting it in either place but my app still gives me the
>following error:
>
>Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
>in FILENAME
>
>Martin S.
i think the easiest way to see php setting is by running info.php script.
if it's not on your webserver, just create one php file with content like
this :
<? echo phpinfo() ?>;
-toto-
idban secandri writes:
> On Saturday 28 April 2001 01:23, you wrote:
> > It's /usr/local/lib/php.ini
>
>
> NEW: Unix install paths changed
> Please note that the PHP 4.0.5 release will have a new set of installation
> paths for any Unix-like operating systems.
> The default php.in path is now "/usr/local/etc" (previously "/usr/local/lib")
> PEAR will be placed in "/usr/local/share/php/pear" (previously
> "/usr/local/lib/php") shared extensions can be found in"/usr/local/lib/php"
>
> http://www.zend.com/zend/week/week34.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
Gurus ,
Problem : my php form has a 4 text field with one row . I want to put an
"add another row" button at the end of the row such that clicking will
bringup the previous row as well as add a new row below it for further
input of data .
let me know ,
thanks and regards,
~Rahul
On Sat, 28 Apr 2001, Adrian D'Costa wrote:
> hi,
>
> I have listed the code below. I have the below table:
> | id | int(11) | | PRI | | auto_increment |
> | operator | varchar(30) | | | | |
> | email | varchar(35) | YES | | | |
> | url | varchar(50) | YES | | | |
>
> I want the operator field to be listed out in four columns and each row to
> have alternate colours. I am able to get it to come out in four columns
> but not the color. Where am I wrong?
>
> <?php
> require("common.php");
> require 'functions.php';
>
> $searchStmt = "select * from toperator order by operator" ;
>
>
> // connect to the db
>
> if (!($link = mysql_pconnect($db_server, $db_login, $db_passwd))){
> DisplayErrMsg(sprintf("internal error %d:%s\n",
> mysql_errno(), mysql_error()));
> exit() ;
> }
>
> // Selct the db
>
> if (!mysql_select_db($db, $link)) {
> DisplayErrMsg(sprintf("Error in selecting %s db", $db)) ;
> DisplayErrMsg(sprintf("error:%d %s", mysql_error($link),
> mysql_error($link))) ;
> exit();
> }
> // Execute the Statement
> if (!($result = mysql_query($searchStmt, $link))) {
> DisplayErrMsg(sprintf("Error in executing %s stmt", $searchStmt));
> DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link),
> mysql_error($link)));
> exit();
> }
>
> $num = mysql_numrows($result);
> include("header.php");
> ?>
> <body bgcolor=white>
> <center>
> <table border=0 width=75% cellpadding=2 cellspacing=3>
>
> <?php
> $i=0;
> $t=0;
> $count=0;
> echo $cfgBgcolorOne;
> echo $cfgBgcolorTwo;
> $bgcolor = $cfgBgcolorOne;
>
> echo("<tr bgcolor=$bgcolor>");
> while($row=mysql_fetch_object($result)) {
> $i % 2 ? 0: $bgcolor = $cfgBgcolorTwo;
> $i++;
>
>
> if($count % 4==0) {
> echo("</tr>");
> echo("<tr bgcolor=$bgcolor>");
> echo $bgcolor;
> }
>
> $count++;
> ?>
> <td><font face=Arial size=2 color=000000><B><?php echo
> $row->operator;?></B></font></td>
> <?php
> if($count % 4==0) {
> echo("</tr>");
> }
> }
>
> ?>
>
> </table></center>
> while($row=mysql_fetch_object($result)) {
> $i % 2 ? 0: $bgcolor = $cfgBgcolorTwo;
> $i++;
>
>
> if($count % 4==0) {
> echo("</tr>");
> echo("<tr bgcolor=$bgcolor>");
> echo $bgcolor;
> }
>
> $count++;
> ?>
> <td><font face=Arial size=2 color=000000><B><?php echo
> $row->operator;?></B></font></td>
> <?php
> if($count % 4==0) {
> echo("</tr>");
> }
> }
>
> ?>
>
> </table></center>
> <?php
> include("footer.php");
> ?>
>
> TIA
>
> Adrian
>
>
Hi!
does anybody of you know like effect a connection to a db access, without use the
ODBC?
Thank you
Hi,
I would like to know how to run du command under PHP.
is this correct ??
exec ("du -ks /home/apache",$test[]);
echo $test[0]; --> I would like to print out the result in web browser
Thank you
Mark
On Saturday 28 April 2001 04:56, you wrote:
> Hi,
>
> I would like to know how to run du command under PHP.
>
> is this correct ??
>
> exec ("du -ks /home/apache",$test[]);
> echo $test[0]; --> I would like to print out the result in web browser
>
> Thank you
>
> Mark
u can use backtick, exec(), system(), passthru()
make sure you read manual first before choosing the right one
ie;
<?
$ps ="ps ax";
echo"<pre>result:\n";
$result = system($ps);
?>
can some one debug this script for me... it say's "Warning: Undefined
variable: total in PHP_poll.php on line 63"
thanxz alot!!!
<?php
// En: Begin PHP Code
/***************************************************************************
***\
* PHP Poll Version 1.0 *
* Copyright 2000 Frederic TYNDIUK (FTLS) All Rights Reserved. *
* E-Mail: [EMAIL PROTECTED] Script License: GPL *
* Created 02/28/2000 Last Modified 02/28/2000 *
* Scripts Archive at: http://www.ftls.org/php/ *
****************************************************************************
***/
// Necessary Variables:
$RESULT_FILE_NAME = "poll_data.txt";
// En: Absolute path and name to file contain poll data.
$QUESTION = "How do you like this Script?";
// En: Question Text.
$ANSWER = array("Love it!", "Like it!", "Its okay..", "I dislike it", "I
hate it..");
// En: All answer.
$IMG_DIR_URL = "./vote";
// En: URL Directory of poll graphs.
$REVOTE_TIME = 3600;
// En: Time (second) after people can revote, use cookies.
// End Necessary Variables section
/***************************************************************************
***/
if (!isset($vote) && !isset($result)) {
echo "<FORM METHOD=\"POST\">\n";
echo "<TABLE CELLSPACING=0 CELLPADDING=2 BORDERCOLOR=#000000
BORDER=1><TR><TD><TABLE WIDTH=\"100%\" BORDER=0>\n";
echo "<TR><TH colspan=\"3\">$QUESTION</TH></TR>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<TR><TD width=\"2%\"></TD><TD align=\"left\" width=\"96%\"><INPUT
TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val</TD><TD
width=\"2%\"></TD></TR>\n";
}
echo "<TR><TD align=\"center\" colspan=\"3\"><INPUT TYPE=\"Submit\"
NAME=\"vote\" VALUE=\" Vote \">\n";
echo " <INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\" Result
\"></TD></TR>\n";
echo "</TABLE></TD></TR></TABLE></FORM>";
} else {
$file_array = file($RESULT_FILE_NAME); // or error("Can not open
\$RESULT_FILE_NAME");
// En: Save result
if ($answer < count($ANSWER) && $vote) {
if (count($file_array) < count($ANSWER)) {
$file_array = array("0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n",
"0\n", "0\n");
}
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w"); //or error("Can not write
\$RESULT_FILE_NAME");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
}
// En: Display result
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<h2>PHP Poll vote results :</h2>";
echo "<TABLE CELLSPACING=0 CELLPADDING=2 WIDTH=400 BORDERCOLOR=#000000
BORDER=1>";
echo "<tr><th>What</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)) {
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$fp += $percent_float;
echo "<tr><td> $ANSWER[$key] </td><td><img height=9
src=\"$IMG_DIR_URL/vote_left.gif\">";
echo "<img height=9 width=\"$percent_int\"
src=\"$IMG_DIR_URL/vote_middle.gif\">";
echo "<img height=9 src=\"$IMG_DIR_URL/vote_right.gif\"> $percent_float %
</td>";
echo "<td><CENTER>$file_array[$key]</CENTER></td></tr>";
}
echo "</TABLE><br>";
}
?>
Dear folks,
I am composing a coding standards for our team. Bottom line, we are
using PEAR, object-oriented programming, extreme programming, and
PHPDoc. Below is the draft so far. I'd greatly appreciate it if
anybody care to give inputs on the document. Nevertheless, I hope
this could be useful to some.
Thank you.
Regards,
Steve
STYLE GUIDE FOR PHP DEVELOPERS
==============================
$Id$
0. General
----------
Understand these points and you are halfway there already.
0.1 We are writing PHP4 application here, not PHP3, nor Perl, Python, etc.
So use PHP idioms.
0.2 We use the PEAR convention, except: 1) the tests in tests/ are written
using unit test as much as possible. 2) preferred error reporting is
slightly different. See 8.2 Reporting error.
0.3 Consistency matters.
0.4 Standards is important.
0.5 Readability matters. Especially since the code will be touched by
several developers.
1. Formatting
-------------
1.0 Enclosing PHP code
Always use <?php ?>.
1.1 Indentation
Preferred indentation is using Tab (interpreted at 4 spaces).
1.2 Text width
If possible, do not write long lines exceeding 79 columns. But this is
not a strict requirement. In many cases it is much more convenient or
vertically readable to put things in one line. So do that instead.
1.3 Curly brace placement
This style:
if (...) {
...
}
is more preferred than:
if (...)
{
...
}
1.4 Whitespaces
- No whitespace after function or method name. Example:
exit()
not
exit ()
$obj->method()
not
$obj->method ()
- Generally, no whitespace inside the enclosing parenthesis, unless it
enhances readability. Examples:
ucfirst($str)
not
ucfirst( $str )
- No whitespace between = in default argument definition.
function f($a, $b=1, $c='')
not
function f($a, $b = 1, $c = '')
- Add whitespace between assignment.
$a = 1;
not
$a=1;
- Whitespace in expressions are usually not necessary. But use them when
they enhance readability.
$a = $b + $c*(5*time());
1.5 Function names
Function names are not case sensitive in PHP. Use the all-lowercase
notation.
1.6 Quotes
Use whichever ones you like. But if you can use '' for simple strings,
and "" only if you need interpolation.
Avoid backslashism! Use ' to quote ", use " to quote '. You can also
utilize PHP4's here-documents.
print <<<EOT;
Some
multiline
text
with
"quotes"
EOT
However, here-document has one disadvantage: it messes indentation. So
choose wisely.
1.7 Blank lines
- Separate each class with two blank lines.
- Separate each function and variable definition in the class with one
blank line.
- Give one blank line after the class definition.
Example:
class MyClass {
function myMethod() {
...
}
var $myAttr1;
var $myAttr2;
}
class YourClass {
}
2. Internationalization
-----------------------
gettext().
3. Comments
-----------
2.1 Inline comments.
Inline comments are used to explain a particular small part of a code.
Example:
$var = 2;
$Good or $var--; // compensate for bad weather
Use inline comments sparingly. Code should already be clear anyway.
2.2 Debugging comments.
# is used to comment out certain parts of a code during debugging.
2.3 Documentation comments.
These use the JavaDoc/PHPDoc syntax. Give to each class, class variable,
method, global constant, and function. Refer to their own documentation.
One place to start: http://java.sun.com/j2se/javadoc/
Below is the summary of the syntax.
/**
* Short description.
*
* @param type $name - description
* @return type description
*
* Longer description .... .... .... .... .... .... .... ....
* .... .... .... .... .... .... .... .... .... .... .... ....
*/
function foo() {
/**
* Short description.
*/
var $foo = '';
/**
* Short description.
*
* @var object ClassName
*/
var $bar;
/** Short description.
*
* Longer description...
*/
define('CONSTANT_NAME', 1);
No blank lines before the definition. A blank comment line between short
description - long description - @param/@return.
3. Naming
---------
3.1 Classes
ClassName
Follow PEAR-style namespace "embedding". For example:
Html_Parser
Data_Item
Data_Collection
3.2 Class attributes
attributeName
_internalAttributeName
attributeNameThatClashesWithBuiltin_ (for example, empty_)
3.3 Methods
methodName
_internalMethodName
methodNameThatClashesWithBuiltin_ (for example, empty_)
3.4 Variables
variable_name
Global_variable_name
this is also acceptable:
variableName
GlobalVariableName
3.4 Constants
CONSTANT_NAME
PEAR-style package prefix:
DB_CONSTANT_NAME
DATA_COLLECTION_CONSTANT_NAME
3.5 Functions
function_name
4. File organization
--------------------
4.1 All library codes will live in the PEAR root directory.
4.2 All PHP libraries and include files, is named with '.php' extension (ie.
no '.lib', '.inc', etc.). Test scripts is named with '.phpt' extension.
4.3 Always try to use register_once() to include libraries. If that is not
possible, use include_once(). Example:
require_once "Data/Collection.php";
4.4 All project- or product-specific library files should live under their
own directory under the PEAR root.
Example:
/this/is/the/pear/root/
Data/
Collection.php
DB/
MyProjName/
MyClass.php
4.5 For now, write one class per file (because of current PHPDoc's
limitation).
5. Testing
----------
5.1 Follow the Extreme Programming methodology.
5.2 Create test scripts and put them in tests/ subdirectory. Use phpunit for
the testing framework.
5.3 How to make test script:
- a test script tests one or more classes;
- name the script file after the [main] class you are testing. Give it
extension .phpt (to avoid PHPDoc parsing the file). For example, if
you want to test Template_Processor, create Template_Processor.phpt in
the Template/tests/ directory.
- require the phpunit file at the very top, to enable maximum warning
level.
- create one or more test case classes. For example,
Template_Processor_TestCase.
- create one function that will return the test suite class (name this
function with the _makeSuite suffix). For example,
Template_Processor_makeSuite. Add all the test case(s) and return the
resulting test case.
- create one test runner class. For example,
Template_Processor_TextRunner.
- instantiate the test runner class. For example, create the object
$Template_Processor_TestRunner. Run the test runner.
See Template_Processor.phpt in the lib/common/Template/tests/ directory
for an example implementation of this.
6. Creating documentation
-------------------------
6.1 For API documentation, use Javadoc syntax. Generate the documentation
using PHPDoc (included with PEAR). See one of the class files to see an
example of this. Refer to the Javadoc manual for more details. A few
tips on writing doc comments:
- Always use:
/**
* One sentence documentation.
*/
Instead of:
/** One sentence documentation. */
PHPDoc gets a little confused with the later.
- The short description is a short sentence, in an imperative tone,
ended with a period.
- If the longer description is composed of more than one paragraphs, use
<p>.
6.2 For other developer documentation (README files, Changelog, etc), use
plain text files (such as this guide).
6.3 For application user documentation, use whatever format you like. Stick
to simple, common, portable format like HTML and PDF.
7. Database programming
-----------------------
Perhaps we will use the database abstraction classes from PEAR in the
future. Currently we only use MySQL, so mysql_* will do. End users will
seldom touch this, however, since we are providing higher level abstraction
classes (for example, through Data_Collection classes).
8. Error handling
-----------------
8.1 Return values
Do always check return values of functions, especially those that
access/manipulate external resources like database (mysql_*), file I/O,
remote URLs, shared memory, etc. Suppress error output of the function
with @ if necessary. For example:
$res = @mysql_query(...);
if (!$res) {
# deal with error...
}
8.2 Reporting error
If you write your own function or method, I recommend a variation of the
PEAR style. The PEAR style is directly returning a PEAR_Error whenever a
function encountered an error condition. I find it rather cumbersome,
since the error checking becomes verbose:
function yourMethod($foo) {
if ($bar) {
# an error condition...
return new PEAR_Error($msg);
}
}
$result = $obj->yourMethod($foo);
if (PEAR::isError($result)) { // cumbersome!
# react accordingly
}
The common idiom is like this:
if (!$obj->yourMethod($foo)) ... // if fails, ...
if ($obj->yourMethod($foo)) ... // if success, ...
Every PHP programmer is familiar to this idiom. It is simple, and
simplicity matters because we will do a bunch of these.
So what we do is store the PEAR_Error object in the object attribute
(recommended name is $error). And we can also use raiseError() directly
if you think the error should potentially stop execution if needed (if
you want to use this style, your class must be a descendant of PEAR).
function yourMethod($foo) {
if ($bar) {
# an error condition...
$this->error = $this->raiseError($msg);
return; // return false
}
return 1; // return success
}
if ($obj->yourMethod($foo)) {
# react accordingly. PEAR_Error is available in $obj->error;
}
This is like the C errno() style but specific per object. Multithreading
is not relevant in the current PHP program so this is not a problem.
In classes that do not subclass PEAR, or in normal functions, you can
use the 'new PEAR_Error()' style.
Let's hope that PHP will soon support exceptions, so handling errors
will become easier.
9. Portability
--------------
9.1 Always use <?php ?>.
9.2 Try to make your library code work with or without register_globals
turned on. Better still, do not use globals at all in the library code.
9.3 magic quotes. This one is a pain to work with portably, since we do not
know whether an argument comes from an external source, or from
GET/POST/Cookie parameter, or neither. Therefore, all library codes
should probably assume magic_quotes_gpc is off, so it does not bother
with stripslashing.
10. References
--------------
- PHP coding standards
- PEAR documentation
- PEAR coding standards
- phpunit documentation
12. Comments, suggestions?
--------------------------
If you do not understand some part, have objection to a certain rule, or
have an idea to improving style, please discuss it with me.
Apr 19, 2001
Steven Haryanto
[EMAIL PROTECTED]
Hi,
How do you add text vars together e.g.
$varone = "hello";
$vartwo = "world";
$varthree = ($varone, $vartwo);
Obviously the above example doesn't work so can someone tell me how to do this?
Thanks
Jamie Saunders
Mail: [EMAIL PROTECTED]
Web: http://jamie-s.co.uk
Jamie Saunders wrote:
> How do you add text vars together e.g.
>
> $varone = "hello";
> $vartwo = "world";
>
> $varthree = ($varone, $vartwo);
$varthree = $varone . $vartwo;
although
$varthree = $varone . ' ' . $vartwo;
might be more appropriate.
regards
Wagner
--
"In place of infinity we usually put some really big number, like 15."
- Anonymous Computer Science professor
Hi all,
I've been trying for many hours to find information on this, but not having
much luck. What i want to do is have an index.php page, and then each link
on that page has a URL like index.php?linkid ie. index.php?links etc
Can anyone point me in the right direction?