---
title: "Type-casting"
canonical_url: "https://handbook.propay.co.za/php/type-casting"
---
# Type-casting

When converting the type of variable, use type-casting instead of dedicated methods. Reason: [better performance](http://tonyshowoff.com/articles/casting-int-faster-than-intval-in-php/).

<code-group>

```php [PHP]
// GOOD
$score = (int) '7';
$hasMadeAnyProgress = (bool) $this->score;

// BAD
$score = intval('7');
$hasMadeAnyProgress = boolval($this->score);
```

</code-group>


## Sitemap

See the full [sitemap](https://handbook.propay.co.za/sitemap.md) for all pages.
