{"id":2431,"date":"2015-05-28T17:27:16","date_gmt":"2015-05-28T16:27:16","guid":{"rendered":"http:\/\/altamiraweb.net\/?p=2431"},"modified":"2015-05-28T17:27:16","modified_gmt":"2015-05-28T16:27:16","slug":"convertir-tipos-de-variables","status":"publish","type":"post","link":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/","title":{"rendered":"Convertir tipos de variables"},"content":{"rendered":"

A veces por cuestiones de c\u00f3digo y programaci\u00f3n necesitaremos cambiar el tipo de variables por ejemplo talvez de double a integer, string a integer, integer a string, etc, para lo cual disponemos de una funcion llamada settype, tal como la misma dice define el tipo de variable, en caso de que funcione devuelve el valor true sino false por lo que podemos usarla con un if del siguiente modo:<\/p>\n

\n<?php
\n$precio=\u00bb123″;
\nif(settype($precio, \u00abinteger\u00bb))
\necho \u00abvariable convertida de string a integer correctamente\u00bb;
\nelse
\necho \u00abError al convertir variable string a integer\u00bb;
\n?>\n<\/p><\/blockquote>\n

En este c\u00f3digo tratamos de convertir la variable string 123 a un valor integer! para poder por ejemplo sumarle valores o restarle o realizar cualquier clase de operaci\u00f3n con \u00e9l<\/p>\n","protected":false},"excerpt":{"rendered":"

A veces por cuestiones de c\u00f3digo y programaci\u00f3n necesitaremos cambiar el tipo de variables por ejemplo talvez de double a integer, string a integer, integer a string, etc, para lo cual disponemos de una funcion llamada settype, tal como la misma dice define el tipo de variable, en caso de que funcione devuelve el valor […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"yoast_head":"\n\u279c Convertir tipos de variables<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u279c Convertir tipos de variables\" \/>\n<meta property=\"og:description\" content=\"A veces por cuestiones de c\u00f3digo y programaci\u00f3n necesitaremos cambiar el tipo de variables por ejemplo talvez de double a integer, string a integer, integer a string, etc, para lo cual disponemos de una funcion llamada settype, tal como la misma dice define el tipo de variable, en caso de que funcione devuelve el valor […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"\u1455\u2776\u1450 Agencia SEO de Marketing Online Altamiraweb\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-28T16:27:16+00:00\" \/>\n<meta name=\"author\" content=\"Altamiraweb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Altamiraweb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\"},\"author\":{\"name\":\"Altamiraweb\",\"@id\":\"https:\/\/altamiraweb.net\/#\/schema\/person\/6bc27ec7043666483d867da3cf42178a\"},\"headline\":\"Convertir tipos de variables\",\"datePublished\":\"2015-05-28T16:27:16+00:00\",\"dateModified\":\"2015-05-28T16:27:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\"},\"wordCount\":131,\"publisher\":{\"@id\":\"https:\/\/altamiraweb.net\/#organization\"},\"articleSection\":[\"Programaci\u00f3n web\"],\"inLanguage\":\"es\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\",\"url\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\",\"name\":\"\u279c Convertir tipos de variables\",\"isPartOf\":{\"@id\":\"https:\/\/altamiraweb.net\/#website\"},\"datePublished\":\"2015-05-28T16:27:16+00:00\",\"dateModified\":\"2015-05-28T16:27:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/altamiraweb.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convertir tipos de variables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/altamiraweb.net\/#website\",\"url\":\"https:\/\/altamiraweb.net\/\",\"name\":\"\u1455\u2776\u1450 Agencia SEO de Marketing Online Altamiraweb\",\"description\":\"\u1455\u2776\u1450 Te ayudamos a alcanzar tus objetivos en internet ? Dise\u00f1o web, Marketing Online y Posicionemiento SEO\",\"publisher\":{\"@id\":\"https:\/\/altamiraweb.net\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/altamiraweb.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/altamiraweb.net\/#organization\",\"name\":\"Altamira Online\",\"url\":\"https:\/\/altamiraweb.net\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/altamiraweb.net\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/altamiraweb.net\/wp-content\/uploads\/2018\/08\/altamiraweb-logoweb-v.png\",\"contentUrl\":\"https:\/\/altamiraweb.net\/wp-content\/uploads\/2018\/08\/altamiraweb-logoweb-v.png\",\"width\":106,\"height\":97,\"caption\":\"Altamira Online\"},\"image\":{\"@id\":\"https:\/\/altamiraweb.net\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/altamiraweb.net\/#\/schema\/person\/6bc27ec7043666483d867da3cf42178a\",\"name\":\"Altamiraweb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/altamiraweb.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b310220437932bda39e1497a25ce9967?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b310220437932bda39e1497a25ce9967?s=96&r=g\",\"caption\":\"Altamiraweb\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u279c Convertir tipos de variables","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/","og_locale":"es_ES","og_type":"article","og_title":"\u279c Convertir tipos de variables","og_description":"A veces por cuestiones de c\u00f3digo y programaci\u00f3n necesitaremos cambiar el tipo de variables por ejemplo talvez de double a integer, string a integer, integer a string, etc, para lo cual disponemos de una funcion llamada settype, tal como la misma dice define el tipo de variable, en caso de que funcione devuelve el valor […]","og_url":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/","og_site_name":"\u1455\u2776\u1450 Agencia SEO de Marketing Online Altamiraweb","article_published_time":"2015-05-28T16:27:16+00:00","author":"Altamiraweb","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Altamiraweb","Tiempo de lectura":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#article","isPartOf":{"@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/"},"author":{"name":"Altamiraweb","@id":"https:\/\/altamiraweb.net\/#\/schema\/person\/6bc27ec7043666483d867da3cf42178a"},"headline":"Convertir tipos de variables","datePublished":"2015-05-28T16:27:16+00:00","dateModified":"2015-05-28T16:27:16+00:00","mainEntityOfPage":{"@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/"},"wordCount":131,"publisher":{"@id":"https:\/\/altamiraweb.net\/#organization"},"articleSection":["Programaci\u00f3n web"],"inLanguage":"es"},{"@type":"WebPage","@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/","url":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/","name":"\u279c Convertir tipos de variables","isPartOf":{"@id":"https:\/\/altamiraweb.net\/#website"},"datePublished":"2015-05-28T16:27:16+00:00","dateModified":"2015-05-28T16:27:16+00:00","breadcrumb":{"@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/altamiraweb.net\/convertir-tipos-de-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/altamiraweb.net\/"},{"@type":"ListItem","position":2,"name":"Convertir tipos de variables"}]},{"@type":"WebSite","@id":"https:\/\/altamiraweb.net\/#website","url":"https:\/\/altamiraweb.net\/","name":"\u1455\u2776\u1450 Agencia SEO de Marketing Online Altamiraweb","description":"\u1455\u2776\u1450 Te ayudamos a alcanzar tus objetivos en internet ? Dise\u00f1o web, Marketing Online y Posicionemiento SEO","publisher":{"@id":"https:\/\/altamiraweb.net\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/altamiraweb.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/altamiraweb.net\/#organization","name":"Altamira Online","url":"https:\/\/altamiraweb.net\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/altamiraweb.net\/#\/schema\/logo\/image\/","url":"https:\/\/altamiraweb.net\/wp-content\/uploads\/2018\/08\/altamiraweb-logoweb-v.png","contentUrl":"https:\/\/altamiraweb.net\/wp-content\/uploads\/2018\/08\/altamiraweb-logoweb-v.png","width":106,"height":97,"caption":"Altamira Online"},"image":{"@id":"https:\/\/altamiraweb.net\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/altamiraweb.net\/#\/schema\/person\/6bc27ec7043666483d867da3cf42178a","name":"Altamiraweb","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/altamiraweb.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b310220437932bda39e1497a25ce9967?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b310220437932bda39e1497a25ce9967?s=96&r=g","caption":"Altamiraweb"}}]}},"_links":{"self":[{"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/posts\/2431"}],"collection":[{"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/comments?post=2431"}],"version-history":[{"count":0,"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/posts\/2431\/revisions"}],"wp:attachment":[{"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/media?parent=2431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/categories?post=2431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/altamiraweb.net\/wp-json\/wp\/v2\/tags?post=2431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}