/    Sign up×
Community /Pin to ProfileBookmark

(int)variable question

I was doing some dev work on an oscommerce site and I noticed that in places oscommerce uses variables in functions expressed like so.

(int)$customer_id

as in

tep_db_query(“select products_id, products_price, products_tax_class_id, products_weight from ” . TABLE_PRODUCTS . ” where products_id = ‘” . (int)$products_id . “‘”);

What does the (int) mean.
Sorry if its a newb question but I have had trouble finding any reference to this in the php online manual.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarJan 31.2008 — it reparses the variable as an integer.

[code=php]var_dump("string");
var_dump( (int) "integer" );
[/code]
Copy linkTweet thisAlerts:
@NogDogJan 31.2008 — If you want to sound properly geeky about it, you are "casting" the value to an integer type. It is synonymous to using the [url=http://www.php.net/int_val]int_val[/url]() function. See the [url=http://www.php.net/manual/en/language.types.type-juggling.php]Type Juggling[/url] section for more info.
×

Success!

Help @celshader spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...