Re: [PHP] foreach on a 3d array
On Tue, 24 Oct 2006 23:55:49 +0200, M.Sokolewicz wrote: > Dotan Cohen wrote: >> On 24/10/06, Chris Boget <[EMAIL PROTECTED]> wrote: >>> > $languages = array( >>> >"af" => array("Afrikaans", "Afrikaans", "South Africa"), >>> >"sq" => array("Albanian", "Shqipe", "Albania")); >>> > >>> > foreach ($languages as $language){ >>> >if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { >>> >print"You are from ".$language[2]."!"; >>> >} >>> > } >>> >>> What you want is something like this: >>> >>> foreach ($languages as $language => $valueArray ){ >>>if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { >>>print"You are from ".$valueArray[2]."!"; >>>} >>> } >>> >>> Your example is setting the variable $language to the array for each >>> iteration. >> >> Thanks, I see what I was missing. >> >>> So the first iteration, >>> >>> $language is set to array("Afrikaans", "Afrikaans", "South Africa") >>> >>> and the second iteration, >>> >>> $language is set to array("Albanian", "Shqipe", "Albania") >> >> That much I knew. Thanks, Chris. >> >> Dotan Cohen >> >> http://essentialinux.com/ >> http://technology-sleuth.com/ > > Why not just do > > if(isset($language[$_HTTP_ACCEPT_LANGUAGE])) { > print 'You are from > '.$language[$_HTTP_ACCEPT_LANGUAGE][3].'!'; > } else { > print 'where are you from?!'; > } Because that wouldn't work :) This variable may contain stuff like "nl,en-us;q=0.7,en;q=0.3". You'll need to do something with this variable first to use array_key_exists (or as you do, isset). That said, I agree that strstr() might not be the best solution. An other note, Dotan: shouldn't $_HTTP_ACCEPT_LANGUAGE actually be $_SERVER['HTTP_ACCEPT_LANGUAGE']? Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strtotime
On Tue, 24 Oct 2006 20:36:08 -0400, Ron Piggott (PHP) wrote: > > I have used the strtotime command to calculate a week ago (among other > things) with syntax like this: > > $one_week_ago = strtotime("-7 days"); > $one_week_ago = date('Y-m-d', $one_week_ago); > > How would you use this command to figure out the last day of the month > in two months from now --- Today is October 24th 2006; the results I am > trying to generate are December 31st 2006. I want to keep the same > result until the end of October and then on November 1st and throughout > November the result to be January 31st 2007 > > Ron My suggestion is: $date = date('Y-m-t', strtotime('+2 months')); $date = date('F jS Y', strtotime($date)); Only two lines of code, only four function calls. As you know, there are many ways to do a thing. Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [PEAR] QUICKFORM JSCALENDAR with "multiple dates feature"
i find jscalendar element for HTML_QuickForm http://www.netsols.de/pear/jscalendar/ i need to use multiple dates feature http://www.dynarch.com/demos/jscalendar/multiple-dates.html anyone can help me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [php] passing variables doesn't work
Dear all, I am trying to pass variables from one php-file to another but that doesn't seem to work. Anyone an idea what I am doing wrong? The first file shows a dropdown with all the databases on the server (only 1 for me). You have to select a database and put an SQL query in the textarea. Pushing "Execute query!" then calls the second file test2.php which should put all the variables on the screen (first there was another routine but that did not work, so I created this simple output to test the veriables). PHP SQL Code Tester Please select the database for the query: " . mysql_tablename($db_table, $i)); } ?> Please input the SQL query to be executed: This routine which is called with the routine above should print all variables but it doesn't. Well, the routine itself works but the variables are empty. PHP SQL code tester ";/* this is printed to the screen */ echo "$wim"; /* this is NOT printed to the screen */ echo "$host"; /* only the is printed */ echo "$database"; /* only the is printed */ echo "query: $query"; /* only the is printed */ echo "Dit is test 2"; /* this is printed to the screen */ ?> Thanks for your help, Wim. DISCLAIMER http://www.proximus.be/maildisclaimer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PEAR] QUICKFORM JSCALENDAR with "multiple dates feature"
Marco Sottana wrote: i find jscalendar element for HTML_QuickForm http://www.netsols.de/pear/jscalendar/ Ask on the pear-general list, you'll get more responses. http://pear.php.net/support/lists.php and please don't cross-post. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [php] passing variables doesn't work
WILLEMS Wim (BMB) wrote: Dear all, I am trying to pass variables from one php-file to another but that doesn't seem to work. Anyone an idea what I am doing wrong? The first file shows a dropdown with all the databases on the server (only 1 for me). You have to select a database and put an SQL query in the textarea. Pushing "Execute query!" then calls the second file test2.php which should put all the variables on the screen (first there was another routine but that did not work, so I created this simple output to test the veriables). PHP SQL Code Tester Please select the database for the query: for ($i = 0; $i < mysql_num_rows($db_table); $i++) { echo("" . mysql_tablename($db_table, $i)); } ?> Please input the SQL query to be executed: This routine which is called with the routine above should print all variables but it doesn't. Well, the routine itself works but the variables are empty. PHP SQL code tester ";/* this is printed to the screen */ echo "$wim"; /* this is NOT printed to the screen */ You're relying on register_globals being on. That's not going to work in 99% of the cases, it's a security issue. Instead everything goes into the $_POST array: echo $_POST['wim'] . ""; If the form action was "get" instead of "post" it would go into the $_GET array. You should also read up on sanitizing user input and sql injection. http://www.phpsec.org/ has quite a few good links on the subject(s). -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [php] passing variables doesn't work
Whatever form information you want to pass has to be part of the form. WILLEMS Wim (BMB) wrote: In the second script, the value of this will be in $_POST["database"]. $wim isn't part of your form - it will /not/ get saved into the next PHP script. You can handle it through input type hidden elements in the form, or through sessions, for example, depending on what you want to do with it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with EXEC and PASSTHRU
I am writing a php website for users to edit a global whitelist for Spam Assassin - all is going fairly well considering I hadn't ever used php until a couple of days ago. My problem is I need to restart AMAVISD-NEW after the user saves the changes. I've acheived this using SUDO and giving the www-data users the rights to SUDO amavisd-new. My problem is simply a user friendlyness issue - below is the code I'm running - if(isset($_POST["SAVE"])) { file_put_contents("/etc/spamassassin/whitelist.cf", $_SESSION[whitelist]); $_SESSION[count]=0; echo "Restarting the service."; exec('sudo /usr/sbin/amavisd-new reload'); echo "Service was restarted.. Returning to the main page."; sleep(4) echo ''; } The problem is that the Restarting the Service dialogue doesn't get displayed until AFTER the Service Restarts even though it appears before the shell_exec command. I've tried exec and passthru and its always the same - I want it to display the "Service was restarted" - wait for 4 seconds and then redirect to the main page. Instead nothing happens on screen for the browser user until the service has restarted at which point they are returned to index.php - its as if the exec and the sleep and the refresh to index.php are all kind of running concurently. Can someone PLEASE tell me what I'm doing wrong - or shed light on how I should do this. Thanks, Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [php] passing variables doesn't work
http://google.com/search?q=phpmyadmin phpmyadmin has all the functionality you are trying to build - and it implements it securely - even if you are writing the code/tool mentioned below as a learning exercise (as opposed to writing it because you need to be able to execute arbitrary queries easily) then the source of the phpmyadmin project is a good resource. WILLEMS Wim (BMB) wrote: > Dear all, > > I am trying to pass variables from one php-file to another but that > doesn't seem to work. Anyone an idea what I am doing wrong? > > The first file shows a dropdown with all the databases on the server > (only 1 for me). You have to select a database and put an SQL query in > the textarea. > Pushing "Execute query!" then calls the second file test2.php which > should put all the variables on the screen (first there was another > routine but that did not work, so I created this simple output to test > the veriables). > > > > PHP SQL Code Tester > > > > $host="localhost"; > $user="some_user"; > $password="some password"; > ?> > > Please select the database for the query: > > $wim = 5; /* this is added to test the passing of the variables - > doesn't work either */ > $link = mysql_connect($host, $user, $password) >or die(" Cannot connect : " . mysql_error()); > $db_table = mysql_list_dbs(); > > for ($i = 0; $i < mysql_num_rows($db_table); $i++) { > echo("" . mysql_tablename($db_table, $i)); > } > ?> > > Please input the SQL query to be executed: > > > > > > > > > This routine which is called with the routine above should print all > variables but it doesn't. Well, the routine itself works but the > variables are empty. > > > PHP SQL code tester > > > > echo "Dit is een test"; /* this is printed to the screen */ > echo "$wim"; /* this is NOT printed to the screen */ > echo "$host";/* only the is printed */ > echo "$database";/* only the is printed */ > echo "query: $query";/* only the is printed */ > echo "Dit is test 2";/* this is printed to the screen */ > ?> > > > > > Thanks for your help, > Wim. > > DISCLAIMER > http://www.proximus.be/maildisclaimer > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with EXEC and PASSTHRU
# [EMAIL PROTECTED] / 2006-10-25 20:35:29 +1300: > I am writing a php website for users to edit a global whitelist for Spam > Assassin - all is going fairly well considering I hadn't ever used php until > a couple of days ago. My problem is I need to restart AMAVISD-NEW after the > user saves the changes. I've acheived this using SUDO and giving the > www-data users the rights to SUDO amavisd-new. My problem is simply a user > friendlyness issue - below is the code I'm running - > > if(isset($_POST["SAVE"])) > { > file_put_contents("/etc/spamassassin/whitelist.cf", $_SESSION[whitelist]); > $_SESSION[count]=0; > echo "Restarting the service."; > exec('sudo /usr/sbin/amavisd-new reload'); > echo "Service was restarted.. Returning to the main page."; > sleep(4) > echo ''; > } > > The problem is that the Restarting the Service dialogue doesn't get > displayed until AFTER the Service Restarts even though it appears before the > shell_exec command. I've tried exec and passthru and its always the same - I > want it to display the "Service was restarted" - wait for 4 seconds and then > redirect to the main page. Instead nothing happens on screen for the browser > user until the service has restarted at which point they are returned to > index.php - its as if the exec and the sleep and the refresh to index.php > are all kind of running concurently. > > Can someone PLEASE tell me what I'm doing wrong - or shed light on how I > should do this. You're forgetting that the server, the browser, and anything between may cache the data into chunks of any size. Even if the browser /did/ receive the data "in real time" your code would be wrong: you're ignoring the basic structure of a HTML document, and any browser worth that label should ignore the meta tag. Do this instead: // ... file_put_contents("/etc/spamassassin/whitelist.cf", $_SESSION[whitelist]); $_SESSION[count]=0; exec('sudo /usr/sbin/amavisd-new reload'); ?> Service was restarted.. Returning to the main page. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] IMAP extension causing delays
> -Original Message- > From: Edward Kay [mailto:[EMAIL PROTECTED] > Sent: 19 October 2006 14:53 > To: php-general@lists.php.net > Subject: [PHP] IMAP extension causing delays > > Hello, > > I need PHP's IMAP extension for my web app but it is really slowing my > server up. > > My setup: Fedora Core 5, Apache 2.2.2, PHP 5.1.4 (run as CGI with suPHP), > PHP IMAP extension - all standard FC5 RPMs. The test page is > simple - just a > call to phpinfo(). > > Without the IMAP extension, the response time is almost > immediate. With the > IMAP extension it takes 2-3 seconds to respond - sometimes as much as 4 > secs. > > Watching with 'top', I can see php-cgi is called immediately when the > request is received. With the IMAP extension installed, after php-cgi > starts, it then drops to the end of the 'top' list, consuming 0% CPU and > 2.0% memory. It remains there for the 2-3 second delay before coming into > play again an running the script quickly. Without the IMAP extension, it > just ends quickly having finished the request. > > From this, it is clear to me there is some major delay being > introduced by > the loading of the IMAP extension. Any ideas on how to resolve this? > > Thanks, > Edward > Thanks to all the suggestions I received on this issue. I have tried running PHP as an Apache module. As Jochem mentioned, this restricts the startup delay to just when Apache starts, not with each request - which is a great improvement. I have also set the various configuration options in the VirtualHost directives so my requirement for separate php.ini files has been removed. There is one remaining issue though - how to get my PHP scripts to run under different usernames for each virtual host. I need my PHP scripts to run as specfic users as they need to interact with the filesystem. I am using suExec and have set the SuexecUserGroup directive for each virtual host, but this isn't used as PHP is not called by CGI. Any suggestions? Thanks, Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
On Wed, 25 Oct 2006 20:35:29 +1300, Matt Beechey wrote: > I am writing a php website for users to edit a global whitelist for Spam > Assassin - all is going fairly well considering I hadn't ever used php until > a couple of days ago. My problem is I need to restart AMAVISD-NEW after the > user saves the changes. I've acheived this using SUDO and giving the > www-data users the rights to SUDO amavisd-new. My problem is simply a user > friendlyness issue - below is the code I'm running - > > if(isset($_POST["SAVE"])) > { > file_put_contents("/etc/spamassassin/whitelist.cf", $_SESSION[whitelist]); > $_SESSION[count]=0; > echo "Restarting the service."; > exec('sudo /usr/sbin/amavisd-new reload'); > echo "Service was restarted.. Returning to the main page."; > sleep(4) > echo ''; > } > > The problem is that the Restarting the Service dialogue doesn't get > displayed until AFTER the Service Restarts even though it appears before the > shell_exec command. I've tried exec and passthru and its always the same - I > want it to display the "Service was restarted" - wait for 4 seconds and then > redirect to the main page. Instead nothing happens on screen for the browser > user until the service has restarted at which point they are returned to > index.php - its as if the exec and the sleep and the refresh to index.php > are all kind of running concurently. > > Can someone PLEASE tell me what I'm doing wrong - or shed light on how I > should do this. www.php.net/flush may help you out, but there are many reasons for even that not to work... such as IE needing at least 256 (out the top of my head) bytes before showing anything, IE needing all data in a before showing it and commonly to make sure you send at least some 20 characters or so before being able to flush() again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [php] passing variables doesn't work
On Wed, 25 Oct 2006 10:19:24 +0200, Max Belushkin wrote: > Whatever form information you want to pass has to be part of the form. > >> WILLEMS Wim (BMB) wrote: >> > > In the second script, the value of this will be in $_POST["database"]. ... which will contain absolutely nothing, since you haven't provided any value: blabla does not contain a value that can be sent to the next page. And, don't build the link to the database (and possibly spawn an error) when you're right into your HTML and just printed to the screen. If the connection fails, the error will most likely not show up, you'll have an empty select box, we'll get a new question from you etc. Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach on a 3d array
On 25/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: Because that wouldn't work :) This variable may contain stuff like "nl,en-us;q=0.7,en;q=0.3". You'll need to do something with this variable first to use array_key_exists (or as you do, isset). That said, I agree that strstr() might not be the best solution. An other note, Dotan: shouldn't $_HTTP_ACCEPT_LANGUAGE actually be $_SERVER['HTTP_ACCEPT_LANGUAGE']? I am using $HTTP_ACCEPT_LANGUAGE. I copied-pested $_HTTP_ACCEPT_LANGUAGE from the first version of the code, which of course didn't work :) $_SERVER['HTTP_ACCEPT_LANGUAGE'] works too. Dotan Cohen http://what-is-what.com/what_is/spam.html http://song-lirics.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach on a 3d array
On Wed, 25 Oct 2006 13:53:47 +0200, Dotan Cohen wrote: > On 25/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: >> >> Because that wouldn't work :) >> >> This variable may contain stuff like "nl,en-us;q=0.7,en;q=0.3". You'll >> need to do something with this variable first to use >> array_key_exists (or as you do, isset). That said, I agree that >> strstr() might not be the best solution. >> >> An other note, Dotan: shouldn't $_HTTP_ACCEPT_LANGUAGE actually be >> $_SERVER['HTTP_ACCEPT_LANGUAGE']? >> > > I am using $HTTP_ACCEPT_LANGUAGE. I copied-pested > $_HTTP_ACCEPT_LANGUAGE from the first version of the code, which of > course didn't work :) $_SERVER['HTTP_ACCEPT_LANGUAGE'] works too. Ah, in that case using $HTTP_ACCEPT_LANGUAGE relies on the register_globals setting, which is a security risk (and turned off by default). Please read up on this, so you know what you're up against... See: http://www.php.net/register_globals Ivo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach on a 3d array
On 25/10/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote: Ah, in that case using $HTTP_ACCEPT_LANGUAGE relies on the register_globals setting, which is a security risk (and turned off by default). Please read up on this, so you know what you're up against... See: http://www.php.net/register_globals Actually, I have read that. I'll pass it on to they guy who manages this server, though. Thanks. Dotan Cohen http://what-is-what.com/what_is/skype.html http://essentialinux.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
Ron Piggott (PHP) wrote: I have used the strtotime command to calculate a week ago (among other things) with syntax like this: $one_week_ago = strtotime("-7 days"); $one_week_ago = date('Y-m-d', $one_week_ago); How would you use this command to figure out the last day of the month in two months from now --- Today is October 24th 2006; the results I am trying to generate are December 31st 2006. I want to keep the same result until the end of October and then on November 1st and throughout November the result to be January 31st 2007 Ron my suggestion: $thefuturedate = mktime(0, 0, 0, date("m") + 3, 0, date("Y")); -- Regards, Clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
Matt Beechey wrote: I am writing a php website for users to edit a global whitelist for Spam Assassin - all is going fairly well considering I hadn't ever used php until a couple of days ago. My problem is I need to restart AMAVISD-NEW after the user saves the changes. I've acheived this using SUDO and giving the www-data users the rights to SUDO amavisd-new. My problem is simply a user friendlyness issue - below is the code I'm running - if(isset($_POST["SAVE"])) { file_put_contents("/etc/spamassassin/whitelist.cf", $_SESSION[whitelist]); $_SESSION[count]=0; echo "Restarting the service."; exec('sudo /usr/sbin/amavisd-new reload'); echo "Service was restarted.. Returning to the main page."; sleep(4) echo ''; } The problem is that the Restarting the Service dialogue doesn't get displayed until AFTER the Service Restarts even though it appears before the shell_exec command. I've tried exec and passthru and its always the same - I want it to display the "Service was restarted" - wait for 4 seconds and then redirect to the main page. Instead nothing happens on screen for the browser user until the service has restarted at which point they are returned to index.php - its as if the exec and the sleep and the refresh to index.php are all kind of running concurently. Can someone PLEASE tell me what I'm doing wrong - or shed light on how I should do this. Thanks, Matt -- You have to keep in mind that you are dealing with the difference in speed between something that is taking place on the sever and something that is being transmitted over a network. You don't make it clear whether this is an in-house site or whether it is used by people at a distance. If the latter, what you describe is not surprising at all. I've never had a reason to look into how PHP sequences events when it pumps out a web page, but it's not unusual for scripts in Perl, for instance, to show delays in browser output when doing something on the server. One consideration would be how long amavisd-new takes to reload. I'm not very well-informed about hacking and security, but it would seem to me that you are taking a risk by giving users root privileges to restart amavisd-new. _ Myron Turner http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
On 24 Oct 2006, at 19:07 , Brad Chow wrote: $date=("2006-10-26"); $date=strtotime($date); $date=date('Y-m-1',$date); $now=strtotime("+3 month", strtotime($date)); $lastday=strtotime("-1 day", $now); echo date('Y-m-d',$lastday); //2006-12-31 Yep, that's pretty much exactly what I do. I suspect there is a much shorter, and more opaque but elegantly clever way of doing it, but that basic methodology has been with me since the mid 80's :) -- One by one the bulbs burned out, like long lives come to their expected ends. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Hosting
Hi, I wanted to give some feedback on PHP 5 hosting in case it helps someone. I signed up with DreamHost last Thursday. I also signed up with OCS Solutions to compare the two services. I also maintain a server with CalPop. When I signed up with Dreamhost, I discovered that you have to fill out a form and fax it to them, along with a rubbing of your credit card. Personally, I found that part rather annoying. They say it's for added security, but I've never had to do that with any other online transactions that I've done. OCS Solutions had me pay for a year up front, which always makes me nervous when checking out a new provider, but they do offer a money back guarantee. Actually, both providers offered a money back guarantee. DreamHost's is 97 days. That's pretty good. Cost-wise, both companies were fairly inexpensive. I ran a Google search for "DreamHost Coupon" and found a coupon that eliminated a majority of the up front cost. Actually, I was pretty surprised. They give you a free domain registration that includes private whois for free. After the coupon, I paid $9.90 and covered the start-up fee (normally $45), the first month of service, and the domain registration. It feels like I paid for a domain registration and got free hosting for a month. My account with DreamHost was created on Monday. Technically, it took 5 days to get my account set up. That's the longest set up delay I've ever experienced with any host provider. OCS Solutions called me an hour after signing up and had my account setup shortly thereafter. I also registered a domain when signing up with OCS Solutions. The whois was wrong. Somehow it ended up showing as registered to one of their employees, but I called and they quickly fixed it. The account was set up under the wrong username, but they fixed that quickly, along with problems with cpanel when it doesn't handle the name change correctly. Mistakes were made, but I was really pleased with how easy it was to get help and I was really happy with how much people obviously cared about helping out. After signing up with DreamHost, the domain that I'd registered with them wasn't working. I was exploring their control panel to figure out the problem when I came upon a DNS management page. The page automatically identified and fixed the problem. That was impressive. Also, I started exploring the DreamHost forums after signing up, something I almost wish I'd done beforehand. I found a lot of posts from very disgruntled customers. It sounds as if they've been running into problems lately on their servers. People complain A LOT about the lack of phone support from DreamHost... you have to submit a trouble ticket for everything. If your account subscription is high enough, they offer a limited number of call backs. The worst part was reading debates between the really happy and the really unhappy DreamHost clients. A lot of the discussions boiled down to verbal attacks between customers. I'm honestly surprised DreamHost didn't intervene. One last thing with OCS, the plan I started on turned out to be insufficient for my needs. I talked with them and they came up with a new plan that does everything I want and just charged me a little more to cover the difference. End result so far... CalPop: I've always had problems with the initial set up of servers at CalPop. Talking with their tech support on the phone is a nightmare; there's something wrong with their phone lines (seems like a really bad voice over IP solution). It usually takes way too many emails to resolve problems. I've also experienced a lot of hardware failures, which makes me wonder about the quality of parts they purchase. Once the server works though, everything seems to settle down until the next problem shows up. DreamHost: Best prices, low service. It seems like DreamHost is run by and tailored toward experienced techies. That's fine, I can work with that. I'm willing to try working with limited phone support. I'm really only concerned with delays I might experience when a problem shows up in something that's mission critical. Beyond that, there are a lot of features available here that aren't elsewhere. I'm getting great value for my money. OCS Solutions: Good prices, but you have to pay up front. Best customer service I've experienced from an ISP so far. I feel a lot more comfortable using them for anything mission critical. On Oct 11, 2006, at 10:12 PM, Kyle wrote: Hello, I would suggest dreamhost at www.dreamhost.com. Their prices look a bit hefty at first but there are referral codes all over the internet and you can end up saving $97. Their plans have tons of bandwidth and space and I haven't had any trouble with it. But I would suggest them highly, their service is quite impressive. And if you don't like the PHP feature
[PHP] How does the Zend engine behave?
Hi, I'm using PHP 4.x and I'm trying to understand a bit about memory usage... Firstly, when I say 'include files' below, I mean all forms, include, require and the _once versions. That said, when a script runs and it's made of several include files, what happens? Are the include files only compiled when execution hits them, or are all include files compiled when the script is first compiled, which would mean a cascade through all statically linked include files. By statically linked files I mean ones like "include ('bob.php')" - i.e the filename isn't in a variable. Secondly, are include files that are referenced, but not used, loaded into memory? I.e Are statically included files automatically loaded into memory at the start of a request? (Of course those where the name is variable can only be loaded once the name has been determined.) And when are they loaded into memory? When the instruction pointer hits the include? Or when the script is initially loaded? Are included files ever unloaded? For instance if I had 3 include files and no loops, once execution had passed from the first include file to the second, the engine might be able to unload the first file. Or at least the code, if not the data. Thirdly, I understand that when a request arrives, the script it requests is compiled before execution. Now suppose a second request arrives for the same script, from a different requester, am I right in assuming that the uncompiled form is loaded? I.e the script is tokenized for each request, and the compiled version is not loaded unless you have engine level caching installed - e.g. MMCache or Zend Optimiser. Fourthly, am I right in understanding that scripts do NOT share memory, even for the portions that are simply instructions? That is, when the second request arrives, the script is loaded again in full. (As opposed to each request sharing the executed/compiled code, but holding data separately.) Fifthly, if a script takes 4MB, given point 4, does the webserver demand 8MB if it is simultaneously servicing 2 requests? Lastly, are there differences in these behaviors for PHP4 and PHP5? Many thanks, Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] exec("mysql -h hhh -u uuu -pppp
i do not get any output from mysql except form echo $bin that displays 1 ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
What is the SQL you are running in test.php? David On 10/25/06, Gert Cuykens <[EMAIL PROTECTED]> wrote: i do not get any output from mysql except form echo $bin that displays 1 ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with EXEC and PASSTHRU
Ok - This is a reply to ALL - Thanks for the great help - I now understand why it wasn't displaying - it was all due to caching of data at the client end before displaying in blocks. With some help in the comments of the php manual for flush() I found a nice script that uses echo str_pad('',1024); to help pad things out - also displays a little countdown to keep people amused and convinced something is happening while the service restarts! I'm LOVING php now - its a very simple language limited only by your imagination as to how you use it! My knowledge seems to be lacking more in HTML and Browser server relationships - I'm basing things on my background in Basic programming as a kid - you do Print "Hello world" and it does that instantly to the screen - little different with browsers! Matt "Myron Turner" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Matt Beechey wrote: >> I am writing a php website for users to edit a global whitelist for Spam >> Assassin - all is going fairly well considering I hadn't ever used php >> until >> a couple of days ago. My problem is I need to restart AMAVISD-NEW after >> the >> user saves the changes. I've acheived this using SUDO and giving the >> www-data users the rights to SUDO amavisd-new. My problem is simply a >> user >> friendlyness issue - below is the code I'm running - >> >> if(isset($_POST["SAVE"])) >> { >> file_put_contents("/etc/spamassassin/whitelist.cf", >> $_SESSION[whitelist]); >> $_SESSION[count]=0; >> echo "Restarting the service."; >> exec('sudo /usr/sbin/amavisd-new reload'); >> echo "Service was restarted.. Returning to the main page."; >> sleep(4) >> echo ''; >> } >> >> The problem is that the Restarting the Service dialogue doesn't get >> displayed until AFTER the Service Restarts even though it appears before >> the >> shell_exec command. I've tried exec and passthru and its always the >> same - I >> want it to display the "Service was restarted" - wait for 4 seconds and >> then >> redirect to the main page. Instead nothing happens on screen for the >> browser >> user until the service has restarted at which point they are returned to >> index.php - its as if the exec and the sleep and the refresh to index.php >> are all kind of running concurently. >> >> Can someone PLEASE tell me what I'm doing wrong - or shed light on how I >> should do this. >> >> Thanks, >> >> Matt > > > -- > You have to keep in mind that you are dealing with the difference in speed > between something that is taking place on the sever and something that is > being transmitted over a network. You don't make it clear whether this is > an in-house site or whether it is used by people at a distance. If the > latter, what you describe is not surprising at all. > > I've never had a reason to look into how PHP sequences events when it > pumps out a web page, but it's not unusual for scripts in Perl, for > instance, to show delays in browser output when doing something on the > server. One consideration would be how long amavisd-new takes to reload. > > I'm not very well-informed about hacking and security, but it would seem > to me that you are taking a risk by giving users root privileges to > restart amavisd-new. > > > _ > Myron Turner > http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
Take this with a grain of salt. I develop with PHP, but I am not an internals guy... [EMAIL PROTECTED] wrote: Are the include files only compiled when execution hits them, or are all include files compiled when the script is first compiled, which would mean a cascade through all statically linked include files. By statically linked files I mean ones like "include ('bob.php')" - i.e the filename isn't in a variable. Compiled when execution hits them. You can prove this by trying to conditionally include a file with a syntax error: if (false) include('script_with_syntax_error.php'); won't cause an error. Secondly, are include files that are referenced, but not used, loaded into memory? I.e Are statically included files automatically loaded into memory at the start of a request? (Of course those where the name is variable can only be loaded once the name has been determined.) And when are they loaded into memory? When the instruction pointer hits the include? Or when the script is initially loaded? If your include file is actually included, it will use memory. If it is not included because of some condition, then it won't use memory. Are included files ever unloaded? For instance if I had 3 include files and no loops, once execution had passed from the first include file to the second, the engine might be able to unload the first file. Or at least the code, if not the data. If you define a global variable in an included file and don't unset it anywhere, then it isn't automatically "unloaded", nor are function/class definitions unloaded when execution is finished. Once you include a file, it isn't unloaded later though - even included files that have just executed statements (no definitions saved for later) seem to eat a little memory once, but it's so minimal that you wouldn't run into problems unless you were including many thousand files. Including the same file again doesn't eat further memory. I assume the eaten memory is for something to do with compilation or caching in the ZE. Thirdly, I understand that when a request arrives, the script it requests is compiled before execution. Now suppose a second request arrives for the same script, from a different requester, am I right in assuming that the uncompiled form is loaded? I.e the script is tokenized for each request, and the compiled version is not loaded unless you have engine level caching installed - e.g. MMCache or Zend Optimiser. I think that's correct. If you don't have an opcode cache, the script is compiled again for every request, regardless of who requests it. IMO, you're probably better off with PECL/APC or eAccelerator rather than MMCache or Zend Optimizer. I use APC personally, and find it exceptional -> rock solid + fast. (eAccelerator had a slight performance edge for my app up until APC's most recent release, where APC now has a significant edge.) Fourthly, am I right in understanding that scripts do NOT share memory, even for the portions that are simply instructions? That is, when the second request arrives, the script is loaded again in full. (As opposed to each request sharing the executed/compiled code, but holding data separately.) Yep, I think that's also correct. Fifthly, if a script takes 4MB, given point 4, does the webserver demand 8MB if it is simultaneously servicing 2 requests? Yep. More usually with webserver/PHP overhead. Lastly, are there differences in these behaviors for PHP4 and PHP5? Significant differences between 4 and 5, but with regards to the above, I think they're more or less the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
actually something like 'asdadsuiashdiasdh' :) test.php is just some text file i maybe should have renamed it to test.txt sorry. But the thing is i dont get any feedback like 'cant connect to host' or 'invalid sql' etc. exec(mysqldump...) works but exec(mysql...) doesnt On 10/25/06, David Giragosian <[EMAIL PROTECTED]> wrote: What is the SQL you are running in test.php? David On 10/25/06, Gert Cuykens <[EMAIL PROTECTED]> wrote: > > i do not get any output from mysql except form echo $bin that displays 1 ? > exec("mysql -h hhh -u uuu - < test.php",$out,$bin); > print_r($out); > echo $bin; > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
What do you get if you run: echo exec("mysql -h hhh -u uuu - wrote: actually something like 'asdadsuiashdiasdh' :) test.php is just some text file i maybe should have renamed it to test.txt sorry. But the thing is i dont get any feedback like 'cant connect to host' or 'invalid sql' etc. exec(mysqldump...) works but exec(mysql...) doesnt On 10/25/06, David Giragosian <[EMAIL PROTECTED]> wrote: > What is the SQL you are running in test.php? > > David > > > On 10/25/06, Gert Cuykens <[EMAIL PROTECTED]> wrote: > > > > i do not get any output from mysql except form echo $bin that displays 1 ? > > > exec("mysql -h hhh -u uuu - < test.php",$out,$bin); > > print_r($out); > > echo $bin; > > ?> > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > >
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
when i do echo exec... i get a blank screen (print_r $out i get Array() echo $bin i get 1) On 10/25/06, David Giragosian <[EMAIL PROTECTED]> wrote: What do you get if you run: echo exec("mysql -h hhh -u uuu - wrote: > actually something like 'asdadsuiashdiasdh' :) test.php is just some > text file i maybe should have renamed it to test.txt sorry. > > But the thing is i dont get any feedback like 'cant connect to host' > or 'invalid sql' etc. > > exec(mysqldump...) works but exec(mysql...) doesnt > > On 10/25/06, David Giragosian < [EMAIL PROTECTED]> wrote: > > What is the SQL you are running in test.php? > > > > David > > > > > > On 10/25/06, Gert Cuykens <[EMAIL PROTECTED] > wrote: > > > > > > i do not get any output from mysql except form echo $bin that displays 1 ? > > > > > exec("mysql -h hhh -u uuu - < test.php",$out,$bin); > > > print_r($out); > > > echo $bin; > > > ?> > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
Gert Cuykens wrote: i do not get any output from mysql except form echo $bin that displays 1 ? I don't know for sure but chances are that mysql outputs errors on stderr not stdout, so you need to redirect stderr to stdout for exec to capture it... exec("mysql -h hhh -u uuu - < test.php 2>&1",$out,$bin); -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
Can't say why you're not getting an error message, but when I have a valid user, password, host, and sql in a .txt file, I get the last record from the select statement I run output in the browser. Maybe start with getting it to work with everything used correctly, then work backwards. HTH, On 10/25/06, Gert Cuykens <[EMAIL PROTECTED]> wrote: when i do echo exec... i get a blank screen (print_r $out i get Array() echo $bin i get 1) On 10/25/06, David Giragosian <[EMAIL PROTECTED]> wrote: > What do you get if you run: > > echo exec("mysql -h hhh -u uuu - > > > > > On 10/25/06, Gert Cuykens <[EMAIL PROTECTED]> wrote: > > actually something like 'asdadsuiashdiasdh' :) test.php is just some > > text file i maybe should have renamed it to test.txt sorry. > > > > But the thing is i dont get any feedback like 'cant connect to host' > > or 'invalid sql' etc. > > > > exec(mysqldump...) works but exec(mysql...) doesnt > > > > On 10/25/06, David Giragosian < [EMAIL PROTECTED]> wrote: > > > What is the SQL you are running in test.php? > > > > > > David > > > > > > > > > On 10/25/06, Gert Cuykens <[EMAIL PROTECTED] > wrote: > > > > > > > > i do not get any output from mysql except form echo $bin that displays > 1 ? > > > > > > > exec("mysql -h hhh -u uuu - < test.php",$out,$bin); > > > > print_r($out); > > > > echo $bin; > > > > ?> > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > >
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
BINGO :) ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1)Array ( [0] => ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1) ) 1 Can you explain a bit more what this do ? 2>&1 For example will i only get stderr or do i get stdout and stderr messages ? On 10/25/06, Stut <[EMAIL PROTECTED]> wrote: Gert Cuykens wrote: > i do not get any output from mysql except form echo $bin that displays 1 ? > exec("mysql -h hhh -u uuu - print_r($out); > echo $bin; > ?> I don't know for sure but chances are that mysql outputs errors on stderr not stdout, so you need to redirect stderr to stdout for exec to capture it... exec("mysql -h hhh -u uuu - < test.php 2>&1",$out,$bin); -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
Gert Cuykens wrote: BINGO :) Indeed. ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1)Array ( [0] => ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1) ) 1 Can you explain a bit more what this do ? 2>&1 For example will i only get stderr or do i get stdout and stderr messages ? The 2>&1 syntax redirects stderr to stdout, it does not do anything with stdout. So yes, you will still also get stdout messages. This no longer has anything to do with PHP. I suggest you Google for info on Linux pipes. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec("mysql -h hhh -u uuu -pppp
ok thx all, works great now :) On 10/25/06, Stut <[EMAIL PROTECTED]> wrote: Gert Cuykens wrote: > BINGO :) Indeed. > ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1)Array ( [0] => > ERROR 2005 (HY000): Unknown MySQL server host 'hhh' (1) ) 1 > > Can you explain a bit more what this do ? 2>&1 For example will i only > get stderr or do i get stdout and stderr messages ? The 2>&1 syntax redirects stderr to stdout, it does not do anything with stdout. So yes, you will still also get stdout messages. This no longer has anything to do with PHP. I suggest you Google for info on Linux pipes. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP]
I am creating a form right now. I am using the html SELECT tag. The most number of days in a month is 31 I want the output to be ## based on the value of $selected_day_of_month variable. For the days of the month where the number is not selected the output I am desiring is 1 2 etc. to be generated through PHP code I already have a value the user submitted in a variable named $selected_day_of_month from being stored in a mySQL table Does anyone know how to do this in a few commands? I am wanting to simplify 1 } ELSE { 1 } if ( $selected_day_of_month == "2" ) } 2 } ELSE { 2 } ?> etc. Ron
Re: [PHP]
Ron Piggott (PHP) wrote: I am creating a form right now. I am using the html SELECT tag. The most number of days in a month is 31 I want the output to be ## based on the value of $selected_day_of_month variable. For the days of the month where the number is not selected the output I am desiring is 1 2 etc. to be generated through PHP code I already have a value the user submitted in a variable named $selected_day_of_month from being stored in a mySQL table Does anyone know how to do this in a few commands? I am wanting to simplify 1 } ELSE { 1 } if ( $selected_day_of_month == "2" ) } 2 } ELSE { 2 } ?> etc. Dang that's painful!! Try this... '.$day.''; } ?> I added a value to the options (you knew that was missing right?). Obviously you need to output the and outside this loop. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach on a 3d array
M.Sokolewicz wrote: Dotan Cohen wrote: On 24/10/06, Chris Boget <[EMAIL PROTECTED]> wrote: > $languages = array( >"af" => array("Afrikaans", "Afrikaans", "South Africa"), >"sq" => array("Albanian", "Shqipe", "Albania")); > > foreach ($languages as $language){ >if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { >print"You are from ".$language[2]."!"; >} > } What you want is something like this: foreach ($languages as $language => $valueArray ){ if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { print"You are from ".$valueArray[2]."!"; } } Your example is setting the variable $language to the array for each iteration. Thanks, I see what I was missing. So the first iteration, $language is set to array("Afrikaans", "Afrikaans", "South Africa") and the second iteration, $language is set to array("Albanian", "Shqipe", "Albania") That much I knew. Thanks, Chris. Dotan Cohen http://essentialinux.com/ http://technology-sleuth.com/ Why not just do if(isset($language[$_HTTP_ACCEPT_LANGUAGE])) { print 'You are from '.$language[$_HTTP_ACCEPT_LANGUAGE][3].'!'; } else { print 'where are you from?!'; } using strstr is pretty slow, and considering you made the indices correspond to the actual value you're checking em for... this is a lot faster ^^ (and cleaner IMO) - tul ofcourse, that should've read: $languages = array( "af" => array("Afrikaans", "Afrikaans", "South Africa"), "sq" => array("Albanian", "Shqipe", "Albania")); if(isset($languages[$_HTTP_ACCEPT_LANGUAGE])) { print 'You are from '.$language[$_HTTP_ACCEPT_LANGUAGE][3].'!'; } else { print 'where are you from?!'; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP]
...and if you wanted to go an extra step you could try an alternate syntax of the exact same code: ' . $day . ''; ?> Either way, Stut is correct. Don't type this out 31 times unless you really really really like to type. ;-) - Joe On 10/25/06, Stut <[EMAIL PROTECTED]> wrote: Ron Piggott (PHP) wrote: > I am creating a form right now. I am using the html SELECT tag. > > > > The most number of days in a month is 31 > > I want the output to be ## based on the value of > $selected_day_of_month variable. For the days of the month where the > number is not selected the output I am desiring is > > 1 > 2 > etc. > > to be generated through PHP code > > I already have a value the user submitted in a variable named > $selected_day_of_month from being stored in a mySQL table > > Does anyone know how to do this in a few commands? I am wanting to > simplify > > if ( $selected_day_of_month == "1" ) } > 1 > } ELSE { > 1 > } > > if ( $selected_day_of_month == "2" ) } > 2 > } ELSE { > 2 > } > > ?> > > etc. Dang that's painful!! Try this... '.$day.''; } ?> I added a value to the options (you knew that was missing right?). Obviously you need to output the and outside this loop. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
At 10/25/2006 04:09 PM, Stut wrote: Dang that's painful!! Try this... '.$day.''; } ?> Ouch! Gnarly mix of logic and markup. I suggest something more like: foreach (range(1, 31) as $day) { $sSelected = ($selected_day_of_month == $day) ? ' selected="selected"' : ''; print <<< hdDay $day hdDay; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote: > At 10/25/2006 04:09 PM, Stut wrote: > >Dang that's painful!! Try this... > > > > > foreach (range(1, 31) as $day) > > { > > print ' > if ($selected_day_of_month == $day) > > print ' selected'; > > print '>'.$day.''; > > } > > > >?> > > > Ouch! Gnarly mix of logic and markup. I suggest something more like: > > foreach (range(1, 31) as $day) > { > $sSelected = ($selected_day_of_month == $day) ? ' > selected="selected"' : ''; > > print <<< hdDay > $day > > hdDay; > } Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I wouldn't consider your above usage one of them :/ Now to add my own flavour... ' .$day .''; } ?> Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does the Zend engine behave?
On Wednesday 25 October 2006 14:48, Jon Anderson wrote: > Take this with a grain of salt. I develop with PHP, but I am not an > internals guy... > > [EMAIL PROTECTED] wrote: > > Are the include files only compiled when execution hits them, or are > > all include files compiled when the script is first compiled, which > > would mean a cascade through all statically linked include files. By > > statically linked files I mean ones like "include ('bob.php')" - i.e > > the filename isn't in a variable. > > Compiled when execution hits them. You can prove this by trying to > conditionally include a file with a syntax error: if (false) > include('script_with_syntax_error.php'); won't cause an error. > > > Secondly, are include files that are referenced, but not used, loaded > > into memory? I.e Are statically included files automatically loaded > > into memory at the start of a request? (Of course those where the name > > is variable can only be loaded once the name has been determined.) And > > when are they loaded into memory? When the instruction pointer hits > > the include? Or when the script is initially loaded? > > If your include file is actually included, it will use memory. If it is > not included because of some condition, then it won't use memory. > > > Are included files ever unloaded? For instance if I had 3 include > > files and no loops, once execution had passed from the first include > > file to the second, the engine might be able to unload the first file. > > Or at least the code, if not the data. > > If you define a global variable in an included file and don't unset it > anywhere, then it isn't automatically "unloaded", nor are function/class > definitions unloaded when execution is finished. > > Once you include a file, it isn't unloaded later though - even included > files that have just executed statements (no definitions saved for > later) seem to eat a little memory once, but it's so minimal that you > wouldn't run into problems unless you were including many thousand > files. Including the same file again doesn't eat further memory. I > assume the eaten memory is for something to do with compilation or > caching in the ZE. > > > Thirdly, I understand that when a request arrives, the script it > > requests is compiled before execution. Now suppose a second request > > arrives for the same script, from a different requester, am I right in > > assuming that the uncompiled form is loaded? I.e the script is > > tokenized for each request, and the compiled version is not loaded > > unless you have engine level caching installed - e.g. MMCache or Zend > > Optimiser. > > I think that's correct. If you don't have an opcode cache, the script is > compiled again for every request, regardless of who requests it. > > IMO, you're probably better off with PECL/APC or eAccelerator rather > than MMCache or Zend Optimizer. I use APC personally, and find it > exceptional -> rock solid + fast. (eAccelerator had a slight performance > edge for my app up until APC's most recent release, where APC now has a > significant edge.) > > > Fourthly, am I right in understanding that scripts do NOT share > > Fifthly, if a script takes 4MB, given point 4, does the webserver > > demand 8MB if it is simultaneously servicing 2 requests? > > Yep. More usually with webserver/PHP overhead. Unless you're using an opcode cache, as I believe some of the are smarter about that. Which and how, I don't know. :-) -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Job Opening
Well since the consensus seemed to be to allow job postings, I'll make one. :-) My company is looking for a few good PHP programmers. We are a Chicago-area web consulting firm developing web sites and web applications for a variety of clients, including several large academic institutions. We are looking for skilled PHP developers to join our team. (Sorry, that means yes, you'd have to work with me.) It's a small but growing company of less than 10 people, all fairly young and geeky. :-) Experience with PHP (although not necessarily prior work experience) is a must. If interested, contact me OFF-LIST for more information. Note: I am NOT in a hiring position, so do NOT send me your resume. :-) I'm just going to pass you on to the person who is. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] heredoc usage [WAS:
> At 10/25/2006 04:09 PM, Stut wrote: > > print ' > if ($selected_day_of_month == $day) > > print ' selected'; > > print '>'.$day.''; On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote: > print <<< hdDay > $day > > hdDay; At 10/25/2006 06:57 PM, Robert Cummings wrote: Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I wouldn't consider your above usage one of them :/ Now to add my own flavour... echo '' .$day .''; Rob, I'd love to know what aspect of my heredoc usage you find objectionable. From my perspective it's a single integrated expression, cleaner, easier to read and proofread, and easier to maintain than a concatenation of expression fragments strung together with syntactical punctuation and quotation marks. I especially value the fact that heredoc lets me separate program logic from text output to the greatest extent possible. Am I unwittingly committing a stylistic or logical faux pas? Conversely, what applications of heredoc do you find valid and valuable? I ask because I use heredoc all the time, sometimes for inline code as above but most often for template assembly, maintaining HTML in external files that can be edited independently of the PHP logic. Curiously, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heredoc usage [WAS:
On Wed, 2006-10-25 at 22:53 -0700, Paul Novitski wrote: > > > At 10/25/2006 04:09 PM, Stut wrote: > > > > print ' > > > if ($selected_day_of_month == $day) > > > > print ' selected'; > > > > print '>'.$day.''; > > On Wed, 2006-10-25 at 17:35 -0700, Paul Novitski wrote: > > > print <<< hdDay > > > $day > > > > > > hdDay; > > At 10/25/2006 06:57 PM, Robert Cummings wrote: > >Ewww, I'll take Stut's style anyday. Heredoc has its uses, but I > >wouldn't consider your above usage one of them :/ Now to add my own > >flavour... > > echo '' > > .$day > > .''; > > > Rob, I'd love to know what aspect of my heredoc usage you find > objectionable. Now this is obviously just opinion since everyone is entitled to their own style, and while I might find it objectionable, I hardly represent the masses and their idiosyncrasies :) Now, the thing that I dislike about heredoc for such small strings is the switching between heredoc mode and the switching back. It's ugly on the scale of switching in and out of PHP tags. it would be less ugly if the closing delimiter didn't have to be at the beginning of it's own line in which case code could still maintain indentation formatting. Understandably it is not like this since it's flexibility lies in being able to place very versatile content within while not accidentally breaking out of heredoc context. To lighten the mess of heredoc I personally use the following format: blah blah blah blah blah blah blah blah blah blah blah blah $foo blah blah blah blah blah blah blah blah blah blah blah blah blah $fee blah blah blah blah blah blah blah blah blah blah blah blah blah _; ?> However that's only useful if indenting the content is not an issue. > From my perspective it's a single integrated > expression, cleaner, easier to read and proofread, and easier to > maintain than a concatenation of expression fragments strung together > with syntactical punctuation and quotation marks. I especially value > the fact that heredoc lets me separate program logic from text output > to the greatest extent possible. Am I unwittingly committing a > stylistic or logical faux pas? > > Conversely, what applications of heredoc do you find valid and valuable? My example also illustrates the kind of content I would be willing to contain within a heredoc... namely a large chunk of content, most likely with a mix of double quotes and variables. That said, I'm still more likely not to use heredoc... I think the one exception where I'm quite likely to use heredoc is when I'm declaring a javascript function from within a PHP function. > I ask because I use heredoc all the time, sometimes for inline code > as above but most often for template assembly, maintaining HTML in > external files that can be edited independently of the PHP logic. I use a tag based template system, there's no PHP in my content so my content files for the most part just look like more HTML. The templates are compiled to PHP (or raw content such as when creating stylesheets) after which they are used over and over without recompiling. here's an example of an email template: Hello , You or somebody posing as you has requested that your password be reset. If you did not request this email then you may disregard it and no changes will be made to your account. To continue please click on the link below and complete the form that will be presented. If clicking on the link does not open your browser then please copy and paste the address into a web browser to continue. http:///reset.php?rid= Sincerely, Admin Here's the code that invokes the template: getServiceRef( 'mail' ); $mail->addTo( $to ); $mail->setSubject( 'BlahBlah.com - Reset Password Request' ); $mail->setTemplate( '//emails/passwordResetDetails.php', $data ); $mail->send(); ?> Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php