php-general Digest 26 Apr 2009 03:38:45 -0000 Issue 6087

Topics (messages 291970 through 291980):

Re: inexplicable behaviour
        291970 by: PJ

Re: PHP CLI vs WebServed
        291971 by: Simon
        291972 by: Daniel Brown
        291977 by: Daniel Brown

Change color of anything in double/single quotes
        291973 by: Andrew Hucks
        291974 by: Marc Steinert
        291975 by: Phpster
        291978 by: Daniel Brown

Re: I need ideas for things to code
        291976 by: Charles Harvey

Formating Numbers
        291979 by: Gary
        291980 by: kranthi

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 ---
Oh, the code works ok. Without the $Count1 = $Count++; it does not work.
If you are saying it should be $Count+; it does not matter. That's
what's weird.
I think it would work no matter what I put in it could be $Count1 =
$Countmeoutandcrap; and I think it would still work.
The similar behaviour was apparent in another code page where I had
exactly the same code repeated once and in the second instance the
"next" worked with the href but in the first it did not. I checked &
checked & checkd and finally I just added a 1 to the first code $Count
and it worked. But any instances of $Count1 were commented out.
I suspect it may have something to do with sessions or with some stack
stuff but I really have no idea.
Thanks for your interest.
Phil


Jônatas Zechim wrote:
> Is the $Count++..
>
> -----Mensagem original-----
> De: PJ [mailto:[email protected]] 
> Enviada em: sexta-feira, 24 de abril de 2009 21:14
> Para: [email protected]
> Assunto: [PHP] inexplicable behaviour
>
> Frankly, I don't know what to look for or why something so weird would
> happen:
> I have pagination set up and the number for pages "next" has a link but
> the "next" does not. I have experimented with all sorts of
> configurations of the code but the only thing that works (and this is
> totally "off the wall") is to do this
> $Count = mysql_num_rows($results);
> $Count1=$Count++; // without this, the "next" does not do the link---
> but there is no other $Count1 in the code either in the original page or
> the include page.
> And this phenomenon was apparent in a similar page.
> I'd be curious to understand how this could happen. I could post the
> whole code, but that would be some 300 lines...
>
>   


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


--- End Message ---
--- Begin Message ---
Thanks for the reply Richard!

> Never done this, but could you set environment variables, which would
> then be picked up by PHP (and stuffed in $_ENV)?

This seems like a good idea, if i mix this with the popen() idea, i
wouldnt need /dev/shm or any files at all then...  but the problem
remains that the PHP code will need to be setup to get its querystring
(and other web-related data) in the $_ENV global instead of whatever
was done before (ie using $_GET, $_COOKIES, etc...)

I could create a simple function that would set all these globals
correctly, copying the info from $_ENV to the proper global var. This
function would need to be placed at the begining of any 'main' php
files (ie index.php but not in the files it includes).

Hopefully, I'm looking for a way that would not require any hacking of
the PHP files that are currently working with other webservers...

Thanks!

--- End Message ---
--- Begin Message ---
On Sat, Apr 25, 2009 at 10:14, Simon <[email protected]> wrote:
>
> Hopefully, I'm looking for a way that would not require any hacking of
> the PHP files that are currently working with other webservers...

    Perhaps you may want to consider hacking PHP itself.  From memory,
one place you may want to start looking is the
php_filter_get_storage() function, then trace back from there.  If
memory continues to serve correctly, it should be in the
`ext/filter/filter.c` file.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
    Replying this back on the list, unchanged and without any
additions from me.... yet.

On Sat, Apr 25, 2009 at 14:09, Simon <[email protected]> wrote:
>>    Perhaps you may want to consider hacking PHP itself.  From memory,
>> one place you may want to start looking is the
>> php_filter_get_storage() function, then trace back from there.  If
>> memory continues to serve correctly, it should be in the
>> `ext/filter/filter.c` file.
>
> Hacking php is probably the most efficient solution, but until i can
> accomplish that, i think i got a good idea...
>
> what if i opened a socket to php with C function popen(), this enables
> to read/write to the stdin/out of the called program (php).  I would
> execute php to read the code from stdin, and the first few lines would
> be created by my 'webserver' and would just set all the correct
> superglobals ($_GET, $_POST, $_SERVER, etc) overwritting whatever is
> in there with the correct information.  Then i would add one last line
> with something like:
> require('theRealPHPfile.php');
> this one would be executed with the proper superglobals set.
>
> the result would give something similar to:
> <?PHP
> $_GET['somevar'] = 'somevalue';
> // [...] more superglobals set here...
> require('index.php');
> ?>
> ----(end of example)----
> This is what my program would do when someone tries to browse to:
> website.com/index.php?somevar=somevalue
>
> I see a loss of performance for creating the header, but other than
> this, i think it should be almost as efficient as hacking php...  and
> being easier...
>
> What do you guys think?
>
> Thanks!
>



-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
If I have something like $string = '"hello" there'; (the word hello is
in double quotes, if you can't see it), how would I output it as
something like <font color=color>"hello"</font> there.

--- End Message ---
--- Begin Message ---
Andrew Hucks wrote:
If I have something like $string = '"hello" there'; (the word hello is
in double quotes, if you can't see it), how would I output it as
something like <font color=color>"hello"</font> there.


Try

$string = preg_replace('/"(.*?)"/', '<font color=color>"\\1"</font>', $string);


Greetings from Germany

Marc Steinert

--
Synchronize and share your files over the web for free
http://bithub.net/

My Twitter feed
http://twitter.com/MarcSteinert





--- End Message ---
--- Begin Message ---


On Apr 25, 2009, at 13:40, Andrew Hucks <[email protected]> wrote:

If I have something like $string = '"hello" there'; (the word hello is
in double quotes, if you can't see it), how would I output it as
something like <font color=color>"hello"</font> there.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Try

Echo "<font color="red">& #34;hello & #34;</font>";

Remove the space between the ampersand and the hash mark


Bastien

--- End Message ---
--- Begin Message ---
On Sat, Apr 25, 2009 at 13:50, Marc Steinert <[email protected]> wrote:
>
> $string = preg_replace('/"(.*?)"/', '<font color=color>"\\1"</font>',
> $string);

    Close, but I'd also recommend dropping in a 'Us' modifier so that
it is `U`ngreedy and `s`pans lines.

<?php
  $regexp = '/"(.*?)"/Us';
?>

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
This was a surprisingly good idea that works for me, as I haven't coded in
about 3 years and need to get my hand back in.  Trying to make use of one
idea led to several others.  Thanks, tedd!

Charles

On Sat, Apr 25, 2009 at 4:54 AM, tedd <[email protected]> wrote:

> At 7:00 PM -0400 4/24/09, Andrew Hucks wrote:
>
>> I've been coding PHP for about a year, and I'm running out of things to
>> code
>> that force me to learn new things. If you have any suggestions, I'd
>> greatly
>> appreciate it.
>>
>
> Andrew:
>
> Here's an idea. Go through the php manuals and make small examples of
> everything you find.
>
> That way not only do you learn, but you have examples to fall back on when
> the need rises.
>
> Here's a small (believe me) portion of the demo's I've written over the
> years:
>
> http://webbytedd.com/a.php
>
> These cover different languages, but it will give you the idea. Just make a
> inventory of examples and post them with code. Not only will it help you,
> but might help others when you answer questions on this list showing the
> solution.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
I cant seem to get this to work for me.  I want the number to be formated to 
money (us, 2 decimal points).  I have gone through manual, tried 
money_format, number_format, along with setting the variable, but I cant 
seem to get it to work. I'm sure it is something simple I am missing.

Thanks for the help.

<?php

$sale_value=$_POST['sale'];
$assess_value=$_POST['assess'];

$mil_rate=.03965;
$ratio=.51;

$present_tax=($assess_value) * ($mil_rate);
$correct_tax=($sale_value)*($ratio)*($mil_rate);
$savings=($present_tax)-($correct_tax);


echo 'According to the information you have entered<br />';?><br />
<?php
echo "You are currently paying now  $ $present_tax<br /><br />";
echo "According to the information you have submitted, your taxes should be 
$ $correct_tax <br />";?>
<br/><?php
echo "According to our calculations, a successful assessment appeal could 
save you annually on your current real estate taxes. <b>$ $savings</b> ";

?> 



--- End Message ---
--- Begin Message ---
pl post the desired result, the functions

if u r trying to get $ 34,567.25
i dont understand y this is not working for u...
http://php.net/manual/en/function.number-format.php#88486

--- End Message ---

Reply via email to