Skip to content

Instantly share code, notes, and snippets.

@MrJSdev
Created March 28, 2017 10:02
Show Gist options
  • Select an option

  • Save MrJSdev/8bf4ddad9471b91663ce42d5bb38cdb8 to your computer and use it in GitHub Desktop.

Select an option

Save MrJSdev/8bf4ddad9471b91663ce42d5bb38cdb8 to your computer and use it in GitHub Desktop.
<?php
$var = 8;
// Inline variable parsing
echo "I'd like {$var} mangoes"; // = "I'd like 8 mangoes
// String concatenation
echo "I'd like ".$var." mangoes"; // I'd like 8 mangoes
// Explicit cast
$items = (string)$var; // $items === "8";
// Function call
$items = strval($var); // $items === "8";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment