php-general Digest 7 Jul 2009 09:21:04 -0000 Issue 6216
Topics (messages 294974 through 294990):
Re: Simple login form with cookies
294974 by: Jason Carson
Re: How to authnticate and use contents from ${HOME}
294975 by: Isaac Dover
Re: best way to properly build an include path *regardless* from where I am
calling the include?
294976 by: Govinda
294977 by: Kim N. Lesmer
294978 by: Daniel Brown
294979 by: Govinda
294980 by: Paul M Foster
294984 by: Clancy
294985 by: Govinda
294988 by: Michael A. Peters
Re: Advise on starting a web store site
294981 by: Paul M Foster
Re: porting C code to php
294982 by: Paul M Foster
Re: How to stop E_DEPRECATED messages in the PHP log?
294983 by: Paul M Foster
294986 by: Jeff Weinberger
Re: What is this called?
294987 by: Michael A. Peters
Re: Call to object function, want to PHP interpret returned string
294989 by: John Allsopp
PHP Manual in PDF format
294990 by: Angus Mann
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]
----------------------------------------------------------------------
--- Begin Message ---
> Jason Carson wrote:
>>> On Mon, Jul 6, 2009 at 02:19, Jason Carson<[email protected]> wrote:
>>>
>>>> ok, I have two sets of scripts here. One uses setcookie() for logging
>>>> into
>>>> the admin panel and the other uses session_start(). Both are working
>>>> fine,
>>>> is one more secure than the other?
>>>>
>>> $_COOKIE data is written to a file that is readable/writeable and
>>> stored on the user's side of things. $_SESSION data is written to the
>>> server, with a cookie stored on the user's side containing just the
>>> PHPSESSID (session ID) string to identify the session file on the
>>> server.
>>>
>>> So determining which is better and/or more secure is really a
>>> matter of the data held there and how it's handled. If storing things
>>> like usernames or you absolutely want to store personal data in an
>>> active session, do so in $_SESSION. If you're storing a password or
>>> credit card number in the active session, you may as well do it in
>>> $_COOKIE, because you're already using an insecure model. ;-P
>>>
>>> --
>>> </Daniel P. Brown>
>>> [email protected] || [email protected]
>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>> Check out our great hosting and dedicated server deals at
>>> http://twitter.com/pilotpig
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>> Well I'm a newbie when it comes to PHP and programming. I guess I need
>> to
>> read up on login security. Do you know of, or recommend, any websites
>> that
>> will show me how to secure my login model (Using cookies or sessions).
>>
>>
> Hi Jason,
> I'm probably not any wiser than you, but I have just (today) discovered
> an interesting site that seems to have some really clear explanations
> and tutorials re php, MySsql et al.
> It's worth looking at (I'm trying to implement something like what you
> are, as well):
> http://www.brainbell.com/tutors/php/php_mysql/Authorizing_User_Access.html
> HTH,
> PJ
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
> http://www.ptahhotep.com
> http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I'll check it out this evening when I have some time. Thanks for the link.
--- End Message ---
--- Begin Message ---
Hi Chantale, as Bastien mentioned, a preconfigured package might be the best
way to go. Wikipedia has more information:
http://en.wikipedia.org/wiki/List_of_LAMP_Packages
What are you wanting to build in your interface?
- Isaac
On Mon, Jul 6, 2009 at 9:14 AM, Bastien Koert <[email protected]> wrote:
> Try xamp or one of the preconfigured packages
>
> bastien
>
> On Sunday, July 5, 2009, <[email protected]> wrote:
> > Hello,
> >
> > My name ich Chantale, I am 15years old and in a german Lycee. I like to
> study Informatic in two years and now try to code my first applications. I
> am new to php and like to code my own Intranet Web-Interface which should
> run on my FileServer at home.
> >
> > I have installed suPHP, but it seems to be not the thing I need, because
> it works only on a VHost.
> >
> > What I need is, that a ${USER} can login and work on her/his ${HOME}.
> >
> > How can I archive this?
> >
> > Thank you
> > Chantale
> >
> >
> >
> >
> >
> >
> >
> > #adBox3 {display:none;}
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Jul 6, 2009, at 9:24 AM, Daniel Brown wrote:
On Mon, Jul 6, 2009 at 11:04, Govinda<[email protected]>
wrote:
Kim, this is exactly what I was looking for. I had been over
$_SERVER in
the docs.. but somehow missed that basic obvious param. Thanks!
And now I'll throw a monkey wrench into the gears and tell you
that, yes, it works, but don't always rely on it. The path translated
to/from the web server may not be the real path. And while you could
do your translation with realpath(), instead you should look into:
<?php include(dirname(dirname(__FILE__)).'/include/
file.php'); ?>
The example above uses the always-on reserved constant __FILE__
for the file in which it's written, regardless of how it's accessed
(as an include, etc.). So consider the following:
/home/user/public_html/index.php
/home/user/public_html/web/home.php
/home/user/public_html/templates/body.tpl.php
/home/user/public_html/include/file.php
In the example above, imagine that you access 'index.php', which
includes 'home.php', which - in turn - includes 'body.tpl.php' and
'file.php'. Using $_SERVER data will use the information given to it
by the webserver at the point of the call: in this case, from
/home/user/public_html/index.php. As such, the include path will be
relative to that. So if you're including a file in ./web/home.php,
you will need to hard-code the adjustment to account for the
difference.
Conversely, using the code example from above (and building upon
it), we know that __FILE__ remains static regardless of the point of
the call. Thus, it's a better and more reliable method, and is usable
even if $_SERVER data is not available to the script.
With this in mind, it should be quite simple to understand how the
following should work:
<?php
// My Name: /home/user/public_html/web/home.php
$file_to_include = dirname(dirname(__FILE__)).'/include/file.php';
if(file_exists($file_to_include) && is_readable($file_to_include)) {
include($file_to_include);
} else {
// Do your error handling here.
}
?>
.... but to each his/her own! ;-P
Michael and Dan
this is great, but then I still do not have a solution that will work
for any level deep of dir/ .
I.e. this-
dirname(dirname(__FILE__))
gives the correct first part of the path to document root like
$_SERVER['DOCUMENT_ROOT'] does
only when called from a file that is 2 levels deep.
I want something that will work for calling an include from any file
that lives n levels deep.
Isn't there anything reliable that effectively says, "from document
root"??
I do not really understand why
$_SERVER['DOCUMENT_ROOT']
should return the right data at one time and not at another. (?)
--
Also, what is the difference between a path that starts with "/",
versus the same path but that does not have that leading "/", or that
same path but prefixed with "./"?
I.e., this:
/somepath/includes/file.php
versus this:
somepath/includes/file.php
versus this:
./somepath/includes/file.php
("../" I know)
-G
--- End Message ---
--- Begin Message ---
On Mon, 6 Jul 2009 16:16:55 -0600
Govinda <[email protected]> wrote:
> I do not really understand why
> $_SERVER['DOCUMENT_ROOT']
> should return the right data at one time and not at another. (?)
In general it will always provide the right data, but as the manual
says: "The entries in this array ($_SERVER) are created by the web
server. There is no guarantee that every web server will provide any of
these; servers may omit some."
The problem could arise if the script is transfered unto a web server
where the $_SERVER array (or parts of it - in this case the
document_root part) has been disabled.
Take into consideration where the script/program has to run and whether
it is likely to be moved around to different web servers with different
setups.
> Also, what is the difference between a path that starts with "/",
> versus the same path but that does not have that leading "/", or
> that same path but prefixed with "./"?
>
> I.e., this:
> /somepath/includes/file.php
This depends on whether the web server is running in a chroot.
If the web server for example has access to all files on the machine
and isn't running in any kind of chroot or limited setup, then
"/somepath" is located in the very root of the directory on that
particular hard drive (or partition) and "/somepath" is NOT a sub
directory of another directory.
So you would see something like this (if you are not using Windows):
/var/www/mywebsite.com/
/somepath/includes/file.php
/usr/sbin/
/home/foo/
> versus this:
> somepath/includes/file.php
This depends on where your script is running from.
If your script is running in:
/var/www/mywebsite.com/myscript.php
Then the above would become:
/var/www/mywebsite.com/somepath/includes/file.php
If your script is running in:
/var/www/mywebsite.com/subdirectory/myscript.php
Then the above would become:
/var/www/mywebsite.com/subdirectory/somepath/includes/file.php
> versus this:
> ./somepath/includes/file.php
Its the same as "somepath/includes/file.php" a "./" means "current
working directory".
I hope I make sense.
If you haven't already take a look at:
http://php.net/manual/en/function.include.php
> ("../" I know)
>
> -G
---
Mange venlige hilsner/Best regards
Kim Naim Lesmer
Programmer/Unix systemadministrator
Web : www.bitflop.com
E-mail : [email protected]
--- End Message ---
--- Begin Message ---
On Mon, Jul 6, 2009 at 18:16, Govinda<[email protected]> wrote:
>
> this is great, but then I still do not have a solution that will work for
> any level deep of dir/ .
> I.e. this-
> dirname(dirname(__FILE__))
> gives the correct first part of the path to document root like
> $_SERVER['DOCUMENT_ROOT'] does
> only when called from a file that is 2 levels deep.
> I want something that will work for calling an include from any file that
> lives n levels deep.
That's where you have to define a variable (or constant) that
tells the system where the web root is located, and then use that to
determine where you are in relation to that. For example:
<?php
function relate_path($me,$root = '/home/pilotpig/public_html') {
if(preg_match('/\/.*\.[a-z0-9]{2,5}$/Ui',$me)) { // If a file with
extension 2-5 alphanum chars
$me = dirname($me); // Strip the filename
// Then loop through the correct number of times.
for($i=0;$i<(substr_count($me,'/') - substr_count($root,'/'));$i++) {
$me = dirname($me);
}
return $me; // Returns the resulting path.
}
return false; // If we were unable to get the path.
}
/*
Then use it as follows, presuming this file is
named /home/user/public_html/web/home.php
*/
if(($path = relate_path(__FILE__)) !== false) {
include($path.'/include/config.php');
} else {
// Handle the error for the incorrect inclusion attempt.
}
?>
Voila!
> Also, what is the difference between a path that starts with "/", versus the
> same path but that does not have that leading "/", or that same path but
> prefixed with "./"?
> I.e., this:
> /somepath/includes/file.php
.... is a true (absolute) path.
> versus this:
> somepath/includes/file.php
.... is a relative path from wherever the file is called.
> versus this:
> ./somepath/includes/file.php
.... is a relative path from the CWD/PWD (Current Working
Directory/Present Working Directory).
P.S. - The function is untested, just rattled off from my brain
while I cook dinner, so if it doesn't work, at least you should get
the gist of where I'm going.... but try it anyway. ;-P
--
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig
--- End Message ---
--- Begin Message ---
I want something that will work for calling an include from any
file that
lives n levels deep.
That's where you have to define a variable (or constant) that
tells the system where the web root is located, and then use that to
determine where you are in relation to that. For example:
<?php
function relate_path($me,$root = '/home/pilotpig/public_html') {
if(preg_match('/\/.*\.[a-z0-9]{2,5}$/Ui',$me)) { // If a file with
extension 2-5 alphanum chars
$me = dirname($me); // Strip the filename
// Then loop through the correct number of times.
for($i=0;$i<(substr_count($me,'/') - substr_count($root,'/'));
$i++) {
$me = dirname($me);
}
return $me; // Returns the resulting path.
}
return false; // If we were unable to get the path.
}
/*
Then use it as follows, presuming this file is
named /home/user/public_html/web/home.php
*/
if(($path = relate_path(__FILE__)) !== false) {
include($path.'/include/config.php');
} else {
// Handle the error for the incorrect inclusion attempt.
}
?>
Voila!
Also, what is the difference between a path that starts with "/",
versus the
same path but that does not have that leading "/", or that same
path but
prefixed with "./"?
I.e., this:
/somepath/includes/file.php
.... is a true (absolute) path.
versus this:
somepath/includes/file.php
.... is a relative path from wherever the file is called.
versus this:
./somepath/includes/file.php
.... is a relative path from the CWD/PWD (Current Working
Directory/Present Working Directory).
P.S. - The function is untested, just rattled off from my brain
while I cook dinner, so if it doesn't work, at least you should get
the gist of where I'm going.... but try it anyway. ;-P
Dan I love to see smart hacks in action! ..and I believe I get what
you are doing.
I am just amazed that there is not a SIMPLE (one-liner) reliable way
of just saying "document root" without a complex function like that.
I mean what we need here is a global include path for the shared-
hosted user .. an include_path that can be set for the virtual server
user and it 'sticks' (does not have to be set on every page load).
I think I'll let this all go for now... I have a lot of basics to
cover before I trip out too much in any one area. I'm going to need
the time and brain juice for some 'real' issues later ;-)
-G
--- End Message ---
--- Begin Message ---
On Mon, Jul 06, 2009 at 07:15:03PM -0600, Govinda wrote:
<snip>
>
> Dan I love to see smart hacks in action! ..and I believe I get what
> you are doing.
> I am just amazed that there is not a SIMPLE (one-liner) reliable way
> of just saying "document root" without a complex function like that.
> I mean what we need here is a global include path for the shared-
> hosted user .. an include_path that can be set for the virtual server
> user and it 'sticks' (does not have to be set on every page load).
> I think I'll let this all go for now... I have a lot of basics to
> cover before I trip out too much in any one area. I'm going to need
> the time and brain juice for some 'real' issues later ;-)
I'm not sure how this could be made simpler.
$site_root = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
Call that in any file in the root of *your* web directories, and you
have what is essentially the "document root" for *your* site.
Presumably, you know the *relative* directories of all your files.
Simply append those relative directories + filenames to the $site_root
variable, and you're done.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Sun, 5 Jul 2009 14:33:07 -0600, [email protected] (Govinda) wrote:
>I am confusing myself reading the docs just now.
>
>i.e.:
>include_path
>basename()
>and dirname()
>
> I had thought from many months ago that
><?php include '/somedir/somefile.php'; ?>
>would include
>somefile.php
>living in
>somedir
>regardless from where in the site structure I am calling it.
>
>Now it does not seem to be doing that.
>
>What is the safest (portable) way to properly build an include path
>*regardless* from where in my site I am calling the include?
>If I understand right I can put includes in a dir/ specified by the
>include_path setting, but I also want to know how to do this from just
>within the root of my virtual server.
I have developed a quite sophisticated development system, which enables me to
have
several different websites using the same software, and allows them all to
share the same
utilities. I know some of you don't like some of the methods I use, but I think
the
general idea is relevant to this discussion.
Each website has a local directory:
D:Websites/Website_1
D:Websites/Website_2
etc.
I also have an independent directory containing the common utilities for all
the websites:
D:Utilities
Each website has one or more divisions, corresponding very roughly to photo
albums. It
also has one directory containing the developmental version of the program, and
a second
containing the working version of the program e.g.
Dev
Wkg
Album_1
etc.
The remote version of each website only has the directories:
Wkg
Utilities
Album_1
etc.
a new web page is invoked with the command:
http://localhost/Website_1/index.php
or
http://www.corybas.com/index.php
If I want to ensure that a fresh version is loaded I add the parameter: ?new=1,
and if I
want to invoke the developmental version, I followed this with the parameter:
&local_dir=Dev.
In either case the program index.php is loaded. This has the following code:
<?php
$wkg_dir = 'Wkg'; $dev_dir = 'Dev'; // Default working version
$program = 'Mailmerge.php'; // Name
of main
program
$new = false;
if (isset($_GET['new'])) { $new = $_GET['new']; }
if ($new == 1) // Unset $local_dir if 'New' set
{ if (isset($_SESSION['local_dir'])) {
unset($_SESSION['local_dir']); }
}
if (!isset($_SESSION['local_dir'])) // Set up session variable
'local_dir'
{ $_SESSION['local_dir'] = $wkg_dir; }
$local_dir = &$_SESSION['local_dir'];
if (isset($_GET['local_dir'])) // Get local_dir, if passed as
parameter
{ $local_dir = $_GET['local_dir']; }
$local_dir = (rtrim($local_dir, "/")); // Verify valid directory
// if (!array_key_exists($local_dir,$dirs)) { $local_dir = $wkg_dir; }
if ($local_dir != $dev_dir) { $local_dir = $wkg_dir; }
// Transfer to real program
include ($local_dir.'/'.$program);
?>
The main program begins by checking whether or not it is running on my home PC
(using a
procedure which caused someone here to say 'Yukk'), but which seems to be both
logically
sound and reliable.
* ---------------------------------------------------------------
1.00 Check if running on home PC & set up defaults
---------------------------------------------------------------*/
$home = strtr(getcwd(),"\\","/"); // Ensure Home contains forward
slashes
if (substr($home,0,2) == 'D:')
{
$is_local = true;
if ($local_dir == 'Dev')
{ $util_dir = $local_dir; }
else { $util_dir = 'D:/Websites/Utilities'; }
}
else
{ $is_local = false; $util_dir = 'Utilities'; }
include ($util_dir.'/Std_utils.php'); // Load standard utilities
// Start real work:
If the parameter $is_local is set, I have access to a suite of editing
facilities, and
other private areas. These are not present on the public copy, and there is
nothing on any
of the menus to suggest that anything is missing.
The parameters $is_local and $local_dir are cached, so they only need to be
specified when
the page is first loaded.
I never change the working directory (and it has never yet changed by itself),
so I can
load anything in any subdirectory simply by specifying the local path. I also
realised
while I was writing this that there is no real reason to have separate Wkg and
Utilities
directories (other than that if I only had one version of the program for all
local sites,
it would make the result of any bug that made it to the working version
potentially that
much more serious).
--- End Message ---
--- Begin Message ---
I'm not sure how this could be made simpler.
$site_root = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
Call that in any file in the root of *your* web directories, and you
have what is essentially the "document root" for *your* site.
Presumably, you know the *relative* directories of all your files.
Simply append those relative directories + filenames to the $site_root
variable, and you're done.
Paul
Paul, you are right. what you say above is very simple.
I guess I just did a poor job of communicating what I was after.
What I wanted was:
($_SERVER['DOCUMENT_ROOT']
..but an equivelent that would work on any server, even if
($_SERVER['DOCUMENT_ROOT'] was turned off.
SO that I could build a universal global include path that would not
break in any page, even if I later moved the page up or down a
directory.. never requiring editing, despite the page's URL changes.
-G
--- End Message ---
--- Begin Message ---
Govinda wrote:
I want something that will work for calling an include from any file
that
lives n levels deep.
That's where you have to define a variable (or constant) that
tells the system where the web root is located, and then use that to
determine where you are in relation to that. For example:
<?php
function relate_path($me,$root = '/home/pilotpig/public_html') {
if(preg_match('/\/.*\.[a-z0-9]{2,5}$/Ui',$me)) { // If a file with
extension 2-5 alphanum chars
$me = dirname($me); // Strip the filename
// Then loop through the correct number of times.
for($i=0;$i<(substr_count($me,'/') -
substr_count($root,'/'));$i++) {
$me = dirname($me);
}
return $me; // Returns the resulting path.
}
return false; // If we were unable to get the path.
}
/*
Then use it as follows, presuming this file is
named /home/user/public_html/web/home.php
*/
if(($path = relate_path(__FILE__)) !== false) {
include($path.'/include/config.php');
} else {
// Handle the error for the incorrect inclusion attempt.
}
?>
Voila!
Also, what is the difference between a path that starts with "/",
versus the
same path but that does not have that leading "/", or that same path but
prefixed with "./"?
I.e., this:
/somepath/includes/file.php
.... is a true (absolute) path.
versus this:
somepath/includes/file.php
.... is a relative path from wherever the file is called.
versus this:
./somepath/includes/file.php
.... is a relative path from the CWD/PWD (Current Working
Directory/Present Working Directory).
P.S. - The function is untested, just rattled off from my brain
while I cook dinner, so if it doesn't work, at least you should get
the gist of where I'm going.... but try it anyway. ;-P
Dan I love to see smart hacks in action! ..and I believe I get what you
are doing.
I am just amazed that there is not a SIMPLE (one-liner) reliable way of
just saying "document root" without a complex function like that.
$documentRoot = '/srv/website/www'
Unless you change your site configuration option, that is both concise
and easy to understand when you (or someone else) reads the code 5
months from now.
--- End Message ---
--- Begin Message ---
On Mon, Jul 06, 2009 at 01:15:10PM +0100, Matthew Croud wrote:
> Hi,
>
> I'm going to start my first e commerce website for a small web shoe
> store.
> I think I know enough PHP to keep my head above water, I'm using an
> add on shopping cart package to deal with the transactions.
>
> My question is, what's the best way to design a site where each
> product appears to have its own page.
>
> Is there a way to create the site *without* having each product have a
> physical separate page ?
>
> Is there a method of web design which makes creating new pages simple
> if they all follow the same pattern. i.e thumbnail, description etc.
Years ago, I used osCommerce for a site like this, and configured it to
present a page full of items in one category. This wasn't done through
PHP but through just configuring osCommerce. I'm not recommending
osCommerce per se (I think it's currently not well maintained), but it
stands to reason that other similar ecommerce suites would allow the
same capability.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Mon, Jul 06, 2009 at 05:24:32PM +0100, Steve Hanselman wrote:
> Hi,
>
> I've some C code that processes files, I want to port this to PHP and am
> trying to decide the best way to port the structs and unions over so as to
> still be readable?
>
> The files are multi-line files with differing layouts depending on the data
> contained within them, so at present unions of structs work very well for
> this.
>
> I'm loathe to turn this code into substr's of the input line, has anybody any
> other ideas?
You could get fancy and handle this with different classes for each
different filetype. Build a parent class which is extended for each
child class.
Or you could just use arrays. Since arrays in PHP can store any type of
data in virtually any configuration, they are roughly equivalent to a
struct in C. The union part isn't necessary, since you can simply
redefine an array or define a different array, depending on the
circumstances.
Your last paragraph puzzled me. I'm guessing that you're reading from
the file some header info (to determine the file type) and then reading
the rest of the file one struct at a time? If so, no, you can't do that
in PHP that way. You could use an fread() call, and read in the number
of bytes you want for a given struct/array, but you're still going to
have to parse the bytes to put them into their respective array members.
You might also try fscanf(), but I'm not sure it will understand binary
data in your file (like floats). Also look at pack() and unpack(), as
these will, to some extent, read and write binary values.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Mon, Jul 06, 2009 at 02:16:09PM -0700, Jeff Weinberger wrote:
> Hi:
>
> I am hoping someone can help me figure this out....
>
> I've just upgraded my PHP installation to 5.3.0. Now I am receiving
> thousands of log messages of the form "PHP Deprecated: ...".
>
> I know I have a number of scripts that use now-deprecated functions,
> etc. and I now know what those are, thanks to all the messages.
>
> However, this is now growing to (literally) gigabytes of log entries,
> so I'd like to stop the messages until I have the time to re-write all
> the offending scripts.
>
> I have tried the following error.reporting lines in php.ini:
>
> error_reporting = E_ALL & ~E_DEPRECATED & E_ERROR & E_WARNING &
> E_PARSE & E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING &
> E_USER_NOTICE & E_COMPILE_ERROR & E_COMPILE_WARNING
>
> error_reporting = ~E_DEPRECATED & E_ALL & E_ERROR & E_WARNING &
> E_PARSE & E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING &
> E_USER_NOTICE & E_COMPILE_ERROR & E_COMPILE_WARNING
>
> error_reporting = E_ALL & E_ERROR & E_WARNING & E_PARSE & E_NOTICE &
> E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING & E_USER_NOTICE &
> E_COMPILE_ERROR & E_COMPILE_WARNING & ~E_DEPRECATED
>
> error_reporting = E_ERROR & E_CORE_ERROR & E_USER_ERROR &
> E_COMPILE_ERROR & E_COMPILE_WARNING & ~E_DEPRECATED
>
> error_reporting = ~E_DEPRECATED & E_ERROR & E_CORE_ERROR &
> E_USER_ERROR & E_COMPILE_ERROR & E_COMPILE_WARNING
>
> (as you can tell, I prefer verbose logs, but not that verbose...).
>
> None of these combinations have stopped the "PHP Deprecated: ..."
> messages.
>
> System info: Mac OS/X 10.5.7 Client version, PHP 5.3.0 running as a
> CGI under Apache 2.2.11 and as a CLI. Please let me know if there's
> any other info that might help.
>
> php_info() reports error.reporting as "0"
>
> Any help or guidance is appreciated!!
Try
error_reporting(E_ALL ^ E_DEPRECATED);
See http://us2.php.net/manual/en/function.error-reporting.php for more
info and examples.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Jul 6, 2009, at 7:47 PM, Paul M Foster wrote:
On Mon, Jul 06, 2009 at 02:16:09PM -0700, Jeff Weinberger wrote:
Hi:
I am hoping someone can help me figure this out....
I've just upgraded my PHP installation to 5.3.0. Now I am receiving
thousands of log messages of the form "PHP Deprecated: ...".
I know I have a number of scripts that use now-deprecated functions,
etc. and I now know what those are, thanks to all the messages.
However, this is now growing to (literally) gigabytes of log entries,
so I'd like to stop the messages until I have the time to re-write
all
the offending scripts.
I have tried the following error.reporting lines in php.ini:
error_reporting = E_ALL & ~E_DEPRECATED & E_ERROR & E_WARNING &
E_PARSE & E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING &
E_USER_NOTICE & E_COMPILE_ERROR & E_COMPILE_WARNING
error_reporting = ~E_DEPRECATED & E_ALL & E_ERROR & E_WARNING &
E_PARSE & E_NOTICE & E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING &
E_USER_NOTICE & E_COMPILE_ERROR & E_COMPILE_WARNING
error_reporting = E_ALL & E_ERROR & E_WARNING & E_PARSE & E_NOTICE &
E_CORE_ERROR & E_USER_ERROR & E_USER_WARNING & E_USER_NOTICE &
E_COMPILE_ERROR & E_COMPILE_WARNING & ~E_DEPRECATED
error_reporting = E_ERROR & E_CORE_ERROR & E_USER_ERROR &
E_COMPILE_ERROR & E_COMPILE_WARNING & ~E_DEPRECATED
error_reporting = ~E_DEPRECATED & E_ERROR & E_CORE_ERROR &
E_USER_ERROR & E_COMPILE_ERROR & E_COMPILE_WARNING
(as you can tell, I prefer verbose logs, but not that verbose...).
None of these combinations have stopped the "PHP Deprecated: ..."
messages.
System info: Mac OS/X 10.5.7 Client version, PHP 5.3.0 running as a
CGI under Apache 2.2.11 and as a CLI. Please let me know if there's
any other info that might help.
php_info() reports error.reporting as "0"
Any help or guidance is appreciated!!
Try
error_reporting(E_ALL ^ E_DEPRECATED);
See http://us2.php.net/manual/en/function.error-reporting.php for more
info and examples.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Paul:
Thanks for your suggestion - it would work nicely, except that that is
a runtime function that is called within a script.
I am trying to get the php.ini setting correct to avoid the Deprecated
messages.
I tried error_reporting=E_ALL & ~E_DEPRECATED (which I think is the
php.ini analogy to your suggestion) to no avail - it failed also.
leaving me still confused....
--Jeff
The achievements of an organization are the results of the combined effort of each
individual. -Vincent Thomas "Vince" Lombardi
--- End Message ---
--- Begin Message ---
and throw your favorite Linux distro on it
(I'm not touching that holy war with a 10' eth0 cord)
I'll touch it.
It shouldn't be Fedora - Fedora has too short of a lifetime before major
version update is necessary to get patches. The main advantages of
Fedora are how new and shiny the desktop is, but a box just for SQL
isn't going to care about new and shiny gnome with the pretty widgets.
Use RHEL/CentOS for this if you like RPM.
Just replace the archaic php 5.1.x and yer good to go ;)
--- End Message ---
--- Begin Message ---
Stuart wrote:
2009/7/6 John Allsopp <[email protected]>:
David Robley wrote:
John Allsopp wrote:
Hi
At the top of a webpage I have:
<?php
include_once("furniture.php");
$myFurniture = new furniture();
echo $myFurniture->getTop("my company title");
?>
to deliver the first lines of HTML, everything in HEAD and the first
bits of page furniture (menu, etc).
In the furniture object in getTop(), I want to return a string that
includes the CSS file that I call with an include_once. But the
include_once isn't interpreted by PHP, it's just outputted. So from:
$toReturn = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0
Transitional//EN' ........
<?php
include_once('styles3.txt');
?>
.......";
return $toReturn;
I get
<?php
include_once('styles3.txt');
?>
in my code.
Do I really have to break up my echo $myFurniture->getTop("my company
title"); call to getTopTop, then include my CSS, then call getTopBottom,
or can I get PHP to interpret that text that came back?
PS. I may be stupid, this may be obvious .. I don't program PHP every day
Thanks in advance for your help :-)
Cheers
J
First guess is that your page doing the including doesn't have a filename
with a .php extension, and your server is set to only parse php in files
with a .php extension.
Cheers
Ah, thanks. It's a PHP object returning a string, I guess the PHP
interpreter won't see that.
So, maybe my object has to write a file that my calling file then includes
after the object function call. Doesn't sound too elegant, but is that how
it's gotta be?
You appear to be looking for the eval function: http://php.net/eval
However, in 99.99% of cases using eval is not the right solution. In
your case there are two ways to solve it.
The first way, assuming the thing you're trying to include is a
stylesheet, is to use an external link to a CSS file. That would be
the "normal" way to include a stylesheet in an HTML page and is far
more efficient that including it inline.
If it's not just a stylesheet that you're including then you'll want
to load the file in the getTop method. For example...
$toReturn = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0
Transitional//EN' ........";
$toReturn.= file_get_contents('styles3.txt');
$toReturn.= '..........';
Simple as that.
-Stuart
Thanks guys. Yes, actually file_get_contents didn't work for me, and yes
you're right, of course I should be including my CSS like <LINK
rel='stylesheet' type='text/css' media='screen' href='style3.css'
title='style1'> in the header.
The style3.txt file I was trying to PHP include was there so I could
include more than one stylesheet and make just one amendment. One for
printing and I'm guessing one for mobile. All that file contained was
the <LINK... line above.
That was legacy code. Now I have a furniture object, of course, I can
put my stylesheet code in one place there just as part of the header,
and have no need for style3.txt.
Thanks for all your help.
J
--- End Message ---
--- Begin Message ---
Hi all. I realize this question has been asked before and I've found responses
in the archive, but none of the links work now, or the files they point to are
old or unsuitable.
I'd like to print the most recent PHP manual to paper, so I need it in a format
that's suitable. I've downloaded it from php.net in chm and HTML format but
neither of them can easily be printed with proper attention to page numbering
and order.
Any idea where to find a PDF or similar version of the manual?
Thanks,
Angus
--- End Message ---