7
I’m converting a string to an integer in PHP, but at the return of settype($variavel, "integer")
, or (int)$variavel
bring me a null value or equal to 1.
Have another way to try the conversion?
The code I’m in trouble with is this:
<script type="text/html" id="javo-map-tab-infobx-content">
<div class="btn-group btn-group-justified pull-right">
<a id="botaoBrief" class="btn btn-primary btn-sm" onclick="window.javo_map_tab_func.brief_run(this);" data-id="{post_id}">
<i class="fa fa-user"></i> <?php _e("Briefaaaa", "javo_fr"); ?>
</a>
<?php
$idPost = '{post_id}';
var_dump($idPost); // resultado-> string(9) "5266"
$idPost = intval($idPost); //resultado-> 0
echo gettype($idPost); //resultado-> integer
intval($idPost); Worked for me
– Welisson Carlos Dias
Greetings to you, Welisson. We are at Stack Overflow in Portuguese, so you can speak in Portuguese yourself; besides, your suggestion has already been given in the other answers, so it wasn’t very clear what you wanted to add with your answer. If it was just a report that worked, you can simply use the website’s voting system. Learn more by doing the [tour] and going to [help].
– Woss