php-general Digest 19 Nov 2010 21:36:15 -0000 Issue 7045

Topics (messages 309570 through 309576):

Re: smary assign var
        309570 by: Steve Staples
        309576 by: Tontonq Tontonq

Re: I am a Windows programmer and getting started on PHP
        309571 by: Alejandro Michelin Salomon
        309572 by: [email protected]
        309573 by: Thiago H. Pojda
        309575 by: Alejandro Michelin Salomon

persistent object caching
        309574 by: Sven Richter

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 ---
On Thu, 2010-11-18 at 22:08 -0500, [email protected] wrote:
> Taking what I understand from C, I think you are looking for this equivalent
> in php.
> 
> $product = array('reduction'=>'4','price_without_reduction'=>'22','price
> '=>'18')
> $yuzde = $product['reduction']*100;
> $yuzde = round($yuzde / $product['price_without_reduction']);
> 
> 
> Echo $yuzde;
> This is no reason to truncate or escape html since the strings do not
> contain them.
> I might suggest you read 
> http://www.php.net/manual/en/function.round.php
> for a better understand the precision options with round.
> 
> 
> 
> 
> Richard L. Buskirk
> 
> 
> -----Original Message-----
> From: Tontonq Tontonq [mailto:[email protected]] 
> Sent: Thursday, November 18, 2010 6:59 PM
> To: PHP General Mailing List
> Subject: [PHP] smary assign var
> 
> hi guys
> i have 2x sub value
> 
> [reduction] => 4
> [price_without_reduction] => 22
> [price] => 18
> 
> and i want to calculate how much i did reduction percent
> 
> {assign var='yuzde' value=$product.reduction*100}
> {assign var='yuzde' value=$yuzde/$product.price_without_reduction}
> 
> -{$yuzde|truncate:3:''|escape:'htmlall':'UTF-8'}%
> when i escape only 3 chars i see some products returns
> like "-18.%"
> when i escape only 2 chars
> i get e result like
> "-5.%"
> 
> so is there a way to round that value to int not float?
> 
> 

would something like this should work... just pieced it from the smarty
site:
http://www.smarty.net/docsv2/en/language.function.math

{math assign='yuzde' equation="x + y" x=$height y=$width format="%.2f"}

Steve

-- 

Steve Staples
Web Application Developer
519.258.2333 x8414


--- End Message ---
--- Begin Message ---
i solved so

{assign var='yuzde' value=$product.reduction*100}
{assign var='yuzde' value=$yuzde/$product.price_without_reduction}

<div style="position: absolute; right: -25px; top: -20px;">
<div class="indirim_resim">-{$yuzde|round:0}%</div>
</div>
</div>

2010/11/19 <[email protected]>

> Taking what I understand from C, I think you are looking for this
> equivalent
> in php.
>
> $product = array('reduction'=>'4','price_without_reduction'=>'22','price
> '=>'18')
> $yuzde = $product['reduction']*100;
> $yuzde = round($yuzde / $product['price_without_reduction']);
>
>
> Echo $yuzde;
> This is no reason to truncate or escape html since the strings do not
> contain them.
> I might suggest you read
> http://www.php.net/manual/en/function.round.php
> for a better understand the precision options with round.
>
>
>
>
> Richard L. Buskirk
>
>
> -----Original Message-----
> From: Tontonq Tontonq [mailto:[email protected]]
> Sent: Thursday, November 18, 2010 6:59 PM
> To: PHP General Mailing List
> Subject: [PHP] smary assign var
>
> hi guys
> i have 2x sub value
>
> [reduction] => 4
> [price_without_reduction] => 22
> [price] => 18
>
> and i want to calculate how much i did reduction percent
>
> {assign var='yuzde' value=$product.reduction*100}
> {assign var='yuzde' value=$yuzde/$product.price_without_reduction}
>
> -{$yuzde|truncate:3:''|escape:'htmlall':'UTF-8'}%
> when i escape only 3 chars i see some products returns
> like "-18.%"
> when i escape only 2 chars
> i get e result like
> "-5.%"
>
> so is there a way to round that value to int not float?
>
>

--- End Message ---
--- Begin Message ---
Daevid Vincent:

I never use XAMP and those type of installations.

Is very simple install Apache on windows ( takes 3 minutes ), and php too.

Install php is simples, run the msi package, the installer configures
httpd.conf

Then you make the changes that you need to php.ini and is complete!!!!. (
enable a extension is just cut off ";" in front of the line, in the php.ini,
and restart apache ).

Simples, fast, get up and running apache and php on windows.

If you need mysql, download the mysql server. Run the installer. The
installer configure the database server.

When i start with php ( 4.0x ), apache is configured manually.
Now is automatic.

All the php developers that i know are windows users. OS is not a problem to
use php.
What install a VM to run linux? If i could run php on windows directly?

Alejandro M.S.

-----Mensagem original-----
De: Daevid Vincent [mailto:[email protected]] 
Enviada em: quinta-feira, 18 de novembro de 2010 19:55
Para: 'Keerat Singh'; [email protected]
Assunto: RE: [PHP] I am a Windows programmer and getting started on PHP

> -----Original Message-----
> Subject: [PHP] I am a Windows programmer and getting started 
> on PHP. What is the easiest way of getting started? Most of 
> the stuff I encounter seems to be very Linux specific.
> 
> I am a Windows programmer and getting started on PHP. What is 
> the easiest way of 
> getting started? Most of the stuff I encounter seems to be 
> very Linux specific.

Personally, I would avoid XAMP and those hacks to run apache and PHP on
your XP (or vista or win7 or whatever). I'd say the vast majority of PHP
developers are LAMP developers so get used to Linux at least enough to move
around the file-system and know where to put files (/var/www/ or
~/public_html etc). With that in mind, I would look for either a pre-built
VM. VirtualBox is free and VERY easy/robust. Also VMWare is outstanding and
they have a free "player" and eight bajillion pre-made VM appliance setups:

http://www.virtualbox.org/
http://www.munkyonline.com/articles/lamp-ubuntu-server-on-virtualbox.html

http://www.vmware.com/products/player/
http://www.vmware.com/appliances/directory/cat/0?k=lamp

I also strongly suggest you setup your VM to use samba shares so it's easy
to edit/save/view your files without some tedious FTP or SCP step.

-Daevid.

P.S. I'd also limit your email subject lines to a simple sentence or less.
Not a paragraph!


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



--- End Message ---
--- Begin Message ---
The reason you might run it on a vm is because not all operating systems are 
created equal. Things that work in Linux won't necessarily work on windows, and 
vice versa. If you're developing on the same type of platform as the live 
server, there is less chance of a problem rearing its head.

For example, the file system is one major area of windows/linux problems. 
Windows isn't case sensitive, while Linux is. In windows, you can have a file 
and a directory with the same name, but not so on Linux. Windows heavily 
restricts the characters you can use in a filename, Linux is much more relaxed.

There is also the problem of all the various modules. Chmod has no real 
function on windows, but is very important on Linux.

It's worth bearing in mind all these issues as you develop.

Thanks,
Ash
http://www.ashleysheridan.co.uk

----- Reply message -----
From: "Alejandro Michelin Salomon" <[email protected]>
Date: Fri, Nov 19, 2010 16:13
Subject: RES: [PHP] I am a Windows programmer and getting started on PHP
To: "'Daevid Vincent'" <[email protected]>
Cc: <[email protected]>


Daevid Vincent:

I never use XAMP and those type of installations.

Is very simple install Apache on windows ( takes 3 minutes ), and php too.

Install php is simples, run the msi package, the installer configures
httpd.conf

Then you make the changes that you need to php.ini and is complete!!!!. (
enable a extension is just cut off ";" in front of the line, in the php.ini,
and restart apache ).

Simples, fast, get up and running apache and php on windows.

If you need mysql, download the mysql server. Run the installer. The
installer configure the database server.

When i start with php ( 4.0x ), apache is configured manually.
Now is automatic.

All the php developers that i know are windows users. OS is not a problem to
use php.
What install a VM to run linux? If i could run php on windows directly?

Alejandro M.S.

-----Mensagem original-----
De: Daevid Vincent [mailto:[email protected]] 
Enviada em: quinta-feira, 18 de novembro de 2010 19:55
Para: 'Keerat Singh'; [email protected]
Assunto: RE: [PHP] I am a Windows programmer and getting started on PHP

> -----Original Message-----
> Subject: [PHP] I am a Windows programmer and getting started 
> on PHP. What is the easiest way of getting started? Most of 
> the stuff I encounter seems to be very Linux specific.
> 
> I am a Windows programmer and getting started on PHP. What is 
> the easiest way of 
> getting started? Most of the stuff I encounter seems to be 
> very Linux specific.

Personally, I would avoid XAMP and those hacks to run apache and PHP on
your XP (or vista or win7 or whatever). I'd say the vast majority of PHP
developers are LAMP developers so get used to Linux at least enough to move
around the file-system and know where to put files (/var/www/ or
~/public_html etc). With that in mind, I would look for either a pre-built
VM. VirtualBox is free and VERY easy/robust. Also VMWare is outstanding and
they have a free "player" and eight bajillion pre-made VM appliance setups:

http://www.virtualbox.org/
http://www.munkyonline.com/articles/lamp-ubuntu-server-on-virtualbox.html

http://www.vmware.com/products/player/
http://www.vmware.com/appliances/directory/cat/0?k=lamp

I also strongly suggest you setup your VM to use samba shares so it's easy
to edit/save/view your files without some tedious FTP or SCP step.

-Daevid.

P.S. I'd also limit your email subject lines to a simple sentence or less.
Not a paragraph!


-- 
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


--- End Message ---
--- Begin Message ---
On Fri, Nov 19, 2010 at 2:13 PM, Alejandro Michelin Salomon <
[email protected]> wrote:

>  > -----Original Message-----
> > Subject: [PHP] I am a Windows programmer and getting started
> > on PHP. What is the easiest way of getting started? Most of
> > the stuff I encounter seems to be very Linux specific.
> >
> > I am a Windows programmer and getting started on PHP. What is
> > the easiest way of
> > getting started? Most of the stuff I encounter seems to be
> > very Linux specific.
>

I use xampp on my desktop at work that runs Windows 7. Installing Apache on
that is sweet, but PHP is nuh-uh. I didn't have the time to make it run
manually as it seems Windows 7 requires you to set the permissions manually
for each file php needs, or something like that.

If you want to just run some scripts to see how the language works, the
fastest and easiest way is installing one of these ready packages, but once
you get a chance, install Apache and PHP separately, this really enlightens
you about how it works internally - which might help you incredbly in the
future.


My 2c,
Thiago Henrique Pojda
+55 41 8856-7925

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

 

De: Alejandro Michelin Salomon [mailto:[email protected]] 
Enviada em: sexta-feira, 19 de novembro de 2010 14:45
Para: '[email protected]'
Assunto: RES: RES: [PHP] I am a Windows programmer and getting started on PHP

 

Daevid Vincent:

For me is no problem if Linux is case sensitive, because all my files ( php, 
JavaScript, html, images, etc ) are lowercase as default.

For my each directory has is own name, and i never use especial characters in 
file names. And chmod i use only in the production server that is a Ubuntu 
Linux,

for some folders that need write access.

 

I run my code on windows in development time, and Linux in production time, 
code runs in both OS, because the rules that i use are good for windows and 
Linux too.

 

Alejandro M.S.

 

De: [email protected] [mailto:[email protected]] 
Enviada em: sexta-feira, 19 de novembro de 2010 12:33
Para: Alejandro Michelin Salomon; 'Daevid Vincent'
Cc: [email protected]
Assunto: Re: RES: [PHP] I am a Windows programmer and getting started on PHP

 

The reason you might run it on a vm is because not all operating systems are 
created equal. Things that work in Linux won't necessarily work on windows, and 
vice versa. If you're developing on the same type of platform as the live 
server, there is less chance of a problem rearing its head.

For example, the file system is one major area of windows/linux problems. 
Windows isn't case sensitive, while Linux is. In windows, you can have a file 
and a directory with the same name, but not so on Linux. Windows heavily 
restricts the characters you can use in a filename, Linux is much more relaxed.

There is also the problem of all the various modules. Chmod has no real 
function on windows, but is very important on Linux.

It's worth bearing in mind all these issues as you develop.

Thanks,
Ash
http://www.ashleysheridan.co.uk

----- Reply message -----
From: "Alejandro Michelin Salomon" <[email protected]>
Date: Fri, Nov 19, 2010 16:13
Subject: RES: [PHP] I am a Windows programmer and getting started on PHP
To: "'Daevid Vincent'" <[email protected]>
Cc: <[email protected]>


Daevid Vincent:

I never use XAMP and those type of installations.

Is very simple install Apache on windows ( takes 3 minutes ), and php too.

Install php is simples, run the msi package, the installer configures
httpd.conf

Then you make the changes that you need to php.ini and is complete!!!!. (
enable a extension is just cut off ";" in front of the line, in the php.ini,
and restart apache ).

Simples, fast, get up and running apache and php on windows.

If you need mysql, download the mysql server. Run the installer. The
installer configure the database server.

When i start with php ( 4.0x ), apache is configured manually.
Now is automatic.

All the php developers that i know are windows users. OS is not a problem to
use php.
What install a VM to run linux? If i could run php on windows directly?

Alejandro M.S.

-----Mensagem original-----
De: Daevid Vincent [mailto:[email protected]] 
Enviada em: quinta-feira, 18 de novembro de 2010 19:55
Para: 'Keerat Singh'; [email protected]
Assunto: RE: [PHP] I am a Windows programmer and getting started on PHP

> -----Original Message-----
> Subject: [PHP] I am a Windows programmer and getting started 
> on PHP. What is the easiest way of getting started? Most of 
> the stuff I encounter seems to be very Linux specific.
> 
> I am a Windows programmer and getting started on PHP. What is 
> the easiest way of 
> getting started? Most of the stuff I encounter seems to be 
> very Linux specific.

Personally, I would avoid XAMP and those hacks to run apache and PHP on
your XP (or vista or win7 or whatever). I'd say the vast majority of PHP
developers are LAMP developers so get used to Linux at least enough to move
around the file-system and know where to put files (/var/www/ or
~/public_html etc). With that in mind, I would look for either a pre-built
VM. VirtualBox is free and VERY easy/robust. Also VMWare is outstanding and
they have a free "player" and eight bajillion pre-made VM appliance setups:

http://www.virtualbox.org/
http://www.munkyonline.com/articles/lamp-ubuntu-server-on-virtualbox.html

http://www.vmware.com/products/player/
http://www.vmware.com/appliances/directory/cat/0?k=lamp

I also strongly suggest you setup your VM to use samba shares so it's easy
to edit/save/view your files without some tedious FTP or SCP step.

-Daevid.

P.S. I'd also limit your email subject lines to a simple sentence or less.
Not a paragraph!


-- 
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




--- End Message ---
--- Begin Message ---
Hello everybody,

our company has completed a webproject with the designgoal to
implement something fast so we have some results. This is what we have
done, and the result is, uhm, however, thats not the point.
Now we are looking for ways to redesign the project with two goals in mind:
1. Build an Application Layer to have some more abstraction and easier
use of our own classes (this one's worked out at most and seems to be
no problem).
2. Gain a lot of speed

We are using php 5.3 and mysql 5.something, our general concept so far
is to have an object for every table in the database and a mapper for
data related methods. Now, when we do something (reading/writing to
db) we go ahead, fetch rows from the DB and convert it to the related
class to work on with the class.
This is slow, way to slow for most things :(
Now we are thinking of caching, yes we know about apc and friends, but
the problem is, most of our objects need to be updated in real time,
f.i. in one tab the user inserts some prices for something, and in the
next one the user gets a list of all prices, including the new one,
and to make things more complicated, its possible for multiple users
to enter prices for the same tab.
So we cannot cache prices, etc. for a certain amount of time, what we
need is a caching system which checks if there is new data and if not,
return the cached object and if so, fetch the new ones, or all
objects, if all objects changed.

I am sure this is something which was solved a lot of times before, so
maybe somebody can point me into a direction where to look for, or to
some example code which handles problems like this one?

Thanks in advance
Sven

--- End Message ---

Reply via email to