The short answer is: it depends on the treatment. Not all treated wood is the same, and the risk to edible plants varies widely.
Older pressure-treated wood made with CCA (chromated copper arsenate) is the biggest concern. CCA contains arsenic and was common in decks, playgrounds, and garden beds before it was voluntarily withdrawn from most residential uses in the early 2000s. Arsenic can leach into soil, especially in acidic or sandy conditions, and root crops like carrots, beets, and radishes, as well as leafy greens, may take up small amounts. The health risk from occasional exposure is usually low, but for a food garden you use year after year, it is better to avoid CCA wood or replace it. Never burn CCA wood; the ash can be highly toxic.
Creosote-treated wood and wood treated with pentachlorophenol are also not recommended for edible gardens. These preservatives contain coal-tar or chlorinated compounds that can leach into soil and may be carcinogenic. Railroad ties and utility poles often fall into this category, so do not use them for vegetables.
Modern pressure-treated wood is different. Most new lumber is treated with copper-based preservatives such as ACQ, CA (copper azole), MCQ, or copper naphthenate. Copper is an essential plant micronutrient, but too much can stunt or kill sensitive plants. Leaching is generally low, but it increases in acidic, low-organic-matter soils. Many extension services consider copper-treated wood acceptable for raised beds, especially if it is lined. The human health risk from copper is much lower than from arsenic, but copper can build up in soil over time.
Borate-treated wood is another option. Boron has low toxicity to people, but it can leach out and damage plants, so it is not ideal for direct soil contact in a planter box. Heat-treated wood contains no chemical preservatives and is safe for edibles, but it usually rots faster than treated or naturally rot-resistant wood.
If you want to grow food in an urban planter box, the safest approach is to use untreated rot-resistant wood such as cedar, redwood, black locust, cypress, or white oak. You can also use brick, stone, concrete, food-grade HDPE plastic, or galvanized metal. If you use treated wood, line the inside with heavy-duty polyethylene (6 mil or thicker), EPDM, or another food-safe liner. Cover the sides and bottom, then add drainage holes so water does not pool. This creates a barrier between the soil and the wood. Keep the liner intact and replace it if it tears.
Other practical tips: avoid salvaged wood of unknown origin, especially old railroad ties, utility poles, and industrial pallets. If you use pallets, look for the "HT" stamp (heat treated) and avoid "MB" (methyl bromide). Wash all produce before eating, peel root crops, and consider testing your soil if you are concerned. Maintain a soil pH around 6.5 to 7.0 and add plenty of compost; this can reduce the availability of some metals. If you already have an old CCA-treated box, do not panic, but consider replacing it or lining it before growing more food. Use it for flowers if you are unsure.
Bottom line: treated wood planter boxes can be safe for edible plants if they use modern copper-based preservatives and are lined, but CCA, creosote, and pentachlorophenol-treated wood should be avoided. When in doubt, line the box or choose untreated, rot-resistant materials.